Beispiel #1
0
 private IdentifierNameSyntax GetAttributeIdentifierName(NameSyntax attributeNameSyntax)
 {
     return(attributeNameSyntax switch
     {
         QualifiedNameSyntax qns => GetAttributeIdentifierName(qns.Right),
         IdentifierNameSyntax ins => ins,
         _ => throw new NotSupportedException(attributeNameSyntax.GetType().Name)
     });
Beispiel #2
0
        private bool IsAttributeName(NameSyntax nameSyntax, string attributeName)
        {
            switch (nameSyntax)
            {
            case SimpleNameSyntax simple:
                return(simple.Identifier.Text == attributeName || simple.Identifier.Text == $"{attributeName}Attribute");

            case QualifiedNameSyntax qualified:
                return(IsAttributeName(qualified.Right, attributeName));
            }

            throw new NotSupportedException($"{nameSyntax.GetType()} not supported as AttributeName.");
        }