-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
If I understand correctly, I'm currently forced to use a string comparison to determine if an invocation expression is nameof, vs some method or delegate:
if ((invocationExpression as IdentifierNameSyntax)?.Identifier.ValueText ==
SyntaxFactory.Token(SyntaxKind.NameOfKeyword).ValueText) [...]I would much prefer access to RawContextualKind and the ContextualKind() extension method just like RawKind and Kind(). Right off the bat it feels cleaner and more performant. Besides that and perhaps more importantly, nameof is a contextual keyword. Sometimes the same token value string could be used for NameOfKeyword, and sometimes it might refer to a method or delegate. The XML docs on RawContextualKind confirm that this is relevant for contexual keywords. This code would be much smarter:
if ((invocationExpression as IdentifierNameSyntax)?.Identifier.ContextualKind() ==
SyntaxKind.NameOfKeyword) [...]Why is the contextual syntactic knowledge stored in RawContextualKind barred from public access? Is there a different API that does provide access?