-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b78dc1
commit d51baae
Showing
12 changed files
with
148 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
namespace Pure.DI.Core.Code; | ||
|
||
internal class Formatter( | ||
ITypeResolver typeResolver, | ||
IComments comments) | ||
: IFormatter | ||
{ | ||
public string Format(Root root) | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append(root.DisplayName); | ||
if (!root.IsMethod) | ||
{ | ||
return sb.ToString(); | ||
} | ||
|
||
var typeArgs= root.TypeDescription.TypeArgs; | ||
if (typeArgs.Count > 0) | ||
{ | ||
sb.Append("<"); | ||
sb.Append(string.Join(", ", typeArgs.Select(i => i.Name))); | ||
sb.Append(">"); | ||
} | ||
|
||
sb.Append('('); | ||
sb.Append(string.Join(", ", root.Args.Select(i => i.VariableName))); | ||
sb.Append(')'); | ||
return sb.ToString(); | ||
} | ||
|
||
public string FormatRef(Root root) | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append(root.DisplayName); | ||
if (!root.IsMethod) | ||
{ | ||
return FormatRef(sb.ToString()); | ||
} | ||
|
||
var typeArgs= root.TypeDescription.TypeArgs; | ||
if (typeArgs.Count > 0) | ||
{ | ||
sb.Append('{'); | ||
sb.Append(string.Join(", ", typeArgs.Select(i => i.Name))); | ||
sb.Append('}'); | ||
} | ||
|
||
sb.Append('('); | ||
sb.Append(string.Join(", ", root.Args.Select(i => i.ContractType))); | ||
sb.Append(')'); | ||
return FormatRef(sb.ToString()); | ||
} | ||
|
||
public string FormatRef(string text) => | ||
$"<see cref=\"{text}\"/>"; | ||
|
||
public string FormatRef(ITypeSymbol type) => | ||
FormatRef( | ||
comments.Escape( | ||
typeResolver.Resolve(type).Name | ||
.Replace('<', '{') | ||
.Replace('>', '}'))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Pure.DI.Core.Code; | ||
|
||
internal interface IFormatter | ||
{ | ||
string Format(Root root); | ||
|
||
string FormatRef(Root root); | ||
|
||
string FormatRef(string text); | ||
|
||
string FormatRef(ITypeSymbol type); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters