@@ -14,6 +14,11 @@ namespace Injectio.Generators;
1414[ Generator ]
1515public class ServiceRegistrationGenerator : IIncrementalGenerator
1616{
17+ private static readonly SymbolDisplayFormat _fullyQualifiedNullableFormat =
18+ SymbolDisplayFormat . FullyQualifiedFormat . AddMiscellaneousOptions (
19+ SymbolDisplayMiscellaneousOptions . IncludeNullableReferenceTypeModifier
20+ ) ;
21+
1722 public void Initialize ( IncrementalGeneratorInitializationContext context )
1823 {
1924 var pipeline = context . SyntaxProvider . CreateSyntaxProvider (
@@ -134,7 +139,7 @@ private static bool SyntacticPredicate(SyntaxNode syntaxNode, CancellationToken
134139
135140 var registration = new ModuleRegistration
136141 (
137- ClassName : methodSymbol . ContainingType . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) ,
142+ ClassName : methodSymbol . ContainingType . ToDisplayString ( _fullyQualifiedNullableFormat ) ,
138143 MethodName : methodSymbol . Name ,
139144 IsStatic : methodSymbol . IsStatic ,
140145 HasTagCollection : hasTagCollection
@@ -252,12 +257,12 @@ private static (EquatableArray<Diagnostic> diagnostics, bool hasServiceCollectio
252257
253258 if ( typeParameter . Name == "TService" || index == 0 )
254259 {
255- var service = typeArgument . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) ;
260+ var service = typeArgument . ToDisplayString ( _fullyQualifiedNullableFormat ) ;
256261 serviceTypes . Add ( service ) ;
257262 }
258263 else if ( typeParameter . Name == "TImplementation" || index == 1 )
259264 {
260- implementationType = typeArgument . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) ;
265+ implementationType = typeArgument . ToDisplayString ( _fullyQualifiedNullableFormat ) ;
261266 }
262267 }
263268 }
@@ -318,7 +323,7 @@ private static (EquatableArray<Diagnostic> diagnostics, bool hasServiceCollectio
318323 // no implementation type set, use class attribute is on
319324 if ( implementationType . IsNullOrWhiteSpace ( ) )
320325 {
321- implementationType = classSymbol . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) ;
326+ implementationType = classSymbol . ToDisplayString ( _fullyQualifiedNullableFormat ) ;
322327 }
323328
324329 // add implemented interfaces
@@ -327,7 +332,7 @@ private static (EquatableArray<Diagnostic> diagnostics, bool hasServiceCollectio
327332 {
328333 foreach ( var implementedInterface in classSymbol . AllInterfaces )
329334 {
330- var interfaceName = implementedInterface . ToDisplayString ( SymbolDisplayFormat . FullyQualifiedFormat ) ;
335+ var interfaceName = implementedInterface . ToDisplayString ( _fullyQualifiedNullableFormat ) ;
331336 serviceTypes . Add ( interfaceName ) ;
332337 }
333338 }
0 commit comments