Skip to content

Commit 5663f9a

Browse files
Globals: Handle fully qualified attribute names
1 parent feb25d6 commit 5663f9a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

EppNet-SourceGen/Source/Globals.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)