@@ -23,15 +23,14 @@ namespace BB84.SourceGenerators;
2323[ Generator ( LanguageNames . CSharp ) ]
2424public sealed class DisposableGenerator : IIncrementalGenerator
2525{
26- private static readonly string GeneratorAttributeName = typeof ( GenerateDisposableAttribute ) . FullName ;
27- private const string AttributeFullName = nameof ( GenerateDisposableAttribute ) ;
28- private static readonly string AttributeShortName = GeneratorHelpers . StripAttributeSuffix ( AttributeFullName ) ;
29- private const string DisposeResourceFullName = nameof ( DisposeResourceAttribute ) ;
30- private static readonly string DisposeResourceShortName = GeneratorHelpers . StripAttributeSuffix ( DisposeResourceFullName ) ;
26+ private static readonly ( string MetadataName , string FullName , string ShortName ) AttributeNames =
27+ GeneratorHelpers . GetAttributeNames < GenerateDisposableAttribute > ( ) ;
28+ private static readonly ( string MetadataName , string FullName , string ShortName ) DisposeResourceAttributeNames =
29+ GeneratorHelpers . GetAttributeNames < DisposeResourceAttribute > ( ) ;
3130
3231 /// <inheritdoc/>
3332 public void Initialize ( IncrementalGeneratorInitializationContext context )
34- => GeneratorHelpers . RegisterClassGenerator ( context , GeneratorAttributeName , Execute ) ;
33+ => GeneratorHelpers . RegisterClassGenerator ( context , AttributeNames . MetadataName , Execute ) ;
3534
3635 private void Execute ( SourceProductionContext context , ( ClassDeclarationSyntax ClassSyntax , SemanticModel SemanticModel ) ? input )
3736 {
@@ -109,7 +108,7 @@ private static (bool generateFinalizer, bool generateAsync) GetAttributeOptions(
109108 {
110109 string name = attribute . Name . ToString ( ) ;
111110
112- if ( name != AttributeShortName && name != AttributeFullName )
111+ if ( name != AttributeNames . ShortName && name != AttributeNames . FullName )
113112 continue ;
114113
115114 if ( attribute . ArgumentList is null || attribute . ArgumentList . Arguments . Count == 0 )
@@ -195,7 +194,7 @@ private static int GetDisposeResourceOrder(FieldDeclarationSyntax fieldDeclarati
195194 {
196195 string name = attribute . Name . ToString ( ) ;
197196
198- if ( name != DisposeResourceShortName && name != DisposeResourceFullName )
197+ if ( name != DisposeResourceAttributeNames . ShortName && name != DisposeResourceAttributeNames . FullName )
199198 continue ;
200199
201200 if ( attribute . ArgumentList is null || attribute . ArgumentList . Arguments . Count == 0 )
0 commit comments