File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -118,11 +118,21 @@ public static class Globals
118118 DiagnosticSeverity . Error ,
119119 isEnabledByDefault : true ) ;
120120
121+ private static string GetAttributeName ( AttributeSyntax attr )
122+ {
123+ return attr . Name switch
124+ {
125+ IdentifierNameSyntax id => id . Identifier . Text ,
126+ QualifiedNameSyntax q => q . Right . Identifier . Text ,
127+ _ => attr . Name . ToString ( )
128+ } ;
129+ }
130+
121131 public static bool HasAttribute ( ClassDeclarationSyntax classNode , string attrName )
122132 {
123133 foreach ( var attrList in classNode . AttributeLists )
124134 foreach ( var attr in attrList . Attributes )
125- if ( attr . Name is IdentifierNameSyntax id && id . Identifier . Text == attrName )
135+ if ( GetAttributeName ( attr ) == attrName )
126136 return true ;
127137
128138 return false ;
@@ -132,7 +142,7 @@ public static bool HasAttribute(MethodDeclarationSyntax methodNode, string attrN
132142 {
133143 foreach ( var attrList in methodNode . AttributeLists )
134144 foreach ( var attr in attrList . Attributes )
135- if ( attr . Name is IdentifierNameSyntax id && id . Identifier . Text == attrName )
145+ if ( GetAttributeName ( attr ) == attrName )
136146 return true ;
137147
138148 return false ;
You can’t perform that action at this time.
0 commit comments