forked from Cysharp/MagicOnion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix DeclaringType code generate issue Cysharp#643
- Loading branch information
1 parent
c5cb55b
commit 5092c94
Showing
2 changed files
with
33 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Text; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace MagicOnion.Generator.Utils; | ||
|
||
internal static class TypeExtensions | ||
{ | ||
public static string GetFullDeclaringTypeName(this Type type) | ||
{ | ||
var typeNameParts = new List<string>(); | ||
while (type != null) | ||
{ | ||
typeNameParts.Insert(0, type.Name); | ||
type = type.DeclaringType; | ||
} | ||
return string.Join(".", typeNameParts); | ||
} | ||
|
||
public static string GetFullDeclaringTypeName(this ITypeSymbol typeSymbol) | ||
{ | ||
return typeSymbol.ToDisplayString( | ||
new SymbolDisplayFormat( | ||
SymbolDisplayGlobalNamespaceStyle.OmittedAsContaining, | ||
SymbolDisplayTypeQualificationStyle.NameAndContainingTypes, | ||
SymbolDisplayGenericsOptions.None, | ||
miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable | ||
)); | ||
} | ||
|
||
} |