11using System . Collections ;
22using System . Collections . Concurrent ;
33using System . Collections . Immutable ;
4+ using System . Runtime . InteropServices ;
45using DynamoDBGenerator . SourceGenerator . Types ;
56using Microsoft . CodeAnalysis ;
67
@@ -55,13 +56,14 @@ public static Func<ITypeSymbol, T> CacheFactory<T>(IEqualityComparer<ISymbol> co
5556 new ( SymbolEqualityComparer . IncludeNullability ) ;
5657
5758 public static bool IsNullable ( this ITypeSymbol typeSymbol ) => typeSymbol switch
58- {
59- { IsReferenceType : true , NullableAnnotation : NullableAnnotation . None or NullableAnnotation . Annotated } => true ,
60- { IsReferenceType : true , NullableAnnotation : NullableAnnotation . NotAnnotated } => false ,
61- { IsValueType : true , OriginalDefinition . SpecialType : SpecialType . System_Nullable_T } => true ,
62- { IsValueType : true } => false ,
63- _ => throw new ArgumentOutOfRangeException ( $ "Could not determine nullablity of type '{ typeSymbol . ToDisplayString ( ) } '.")
64- } ;
59+ {
60+ { IsReferenceType : true , NullableAnnotation : NullableAnnotation . None or NullableAnnotation . Annotated } => true ,
61+ { IsReferenceType : true , NullableAnnotation : NullableAnnotation . NotAnnotated } => false ,
62+ { IsValueType : true , OriginalDefinition . SpecialType : SpecialType . System_Nullable_T } => true ,
63+ { IsValueType : true } => false ,
64+ _ => throw new ArgumentOutOfRangeException (
65+ $ "Could not determine nullablity of type '{ typeSymbol . ToDisplayString ( ) } '.")
66+ } ;
6567
6668 public static TypeIdentifier TypeIdentifier ( this ITypeSymbol type )
6769 {
@@ -179,6 +181,7 @@ private static int CombineHashCodes(int h1, int h2)
179181 return ( ( h1 << 5 ) + h1 ) ^ h2 ;
180182 }
181183 }
184+
182185 public static Func < ITypeSymbol , ITypeSymbol , string > SuffixedFullyQualifiedTypeName ( string suffix ,
183186 IEqualityComparer < ISymbol ? > comparer )
184187 {
@@ -187,7 +190,7 @@ public static Func<ITypeSymbol, ITypeSymbol, string> SuffixedFullyQualifiedTypeN
187190 if ( Equals ( comparer , SymbolEqualityComparer . Default ) )
188191 {
189192 return ( x , y ) => dict . GetOrAdd (
190- ( x , y ) ,
193+ ( x , y ) ,
191194 tuple =>
192195 {
193196 var ( p , c ) = tuple ;
@@ -202,6 +205,10 @@ public static Func<ITypeSymbol, ITypeSymbol, string> SuffixedFullyQualifiedTypeN
202205 ) ;
203206 }
204207
208+ private static readonly SymbolDisplayFormat DisplayFormat = new (
209+ genericsOptions : SymbolDisplayGenericsOptions . IncludeTypeParameters
210+ ) ;
211+
205212 public static Func < ITypeSymbol , string > SuffixedTypeSymbolNameFactory ( string ? suffix ,
206213 IEqualityComparer < ISymbol ? > comparer )
207214 {
@@ -217,8 +224,8 @@ public static Func<ITypeSymbol, string> SuffixedTypeSymbolNameFactory(string? su
217224 return x => dict . GetOrAdd ( x ,
218225 y => y is IArrayTypeSymbol
219226 ? $ "{ y . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat ) } _{ y . BaseType ! . ToDisplayString ( ) } "
220- : y . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat ) . ToAlphaNumericMethodName ( )
221- ) ;
227+ : y . ToDisplayString (
228+ DisplayFormat ) . ToAlphaNumericMethodName ( ) ) ;
222229
223230 return x => dict . GetOrAdd ( x ,
224231 y => y is IArrayTypeSymbol
@@ -267,11 +274,11 @@ when string.Join("_", namedTypeSymbol.TypeArguments.Select(NullableAnnotation))
267274 _ => throw new NotImplementedException ( ExceptionMessage ( single ) )
268275 } ,
269276 { NullableAnnotation : Microsoft . CodeAnalysis . NullableAnnotation . NotAnnotated } =>
270- $ "NN_{ x . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat ) . ToAlphaNumericMethodName ( ) } ",
277+ $ "NN_{ x . ToDisplayString ( DisplayFormat ) . ToAlphaNumericMethodName ( ) } ",
271278 { NullableAnnotation : Microsoft . CodeAnalysis . NullableAnnotation . None } =>
272- $ "{ x . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat ) . ToAlphaNumericMethodName ( ) } ",
279+ $ "{ x . ToDisplayString ( DisplayFormat ) . ToAlphaNumericMethodName ( ) } ",
273280 { NullableAnnotation : Microsoft . CodeAnalysis . NullableAnnotation . Annotated } =>
274- $ "N_{ x . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat ) . ToAlphaNumericMethodName ( ) } ",
281+ $ "N_{ x . ToDisplayString ( DisplayFormat ) . ToAlphaNumericMethodName ( ) } ",
275282 _ => throw new NotImplementedException ( ExceptionMessage ( x ) )
276283 } ;
277284
0 commit comments