How-to determine if an "nameof" IdentifierToken is a contextual keyword #51788
-
I'd like to do something with nameof expressions. Unfortunately there seems to be no public API to detect if an identifier is a contextual nameof keyword or not. In the roslyn code I found out that there is a Field called Could you make it In addition it is not handled correctly for example by "RoslynQuoter": https://dotnetfiddle.net/J6NPUK. So if you just copy all public property you get errors. But it works if IdentifierName(Identifier(TriviaList(), SyntaxKind.NameOfKeyword, "nameof", "nameof", TriviaList())) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
The right way to do you is to actually check if the name is 'nameof'. It's not a special keyword. In terms of roslyn quoter, it needs to call 'ParseToken' to get the right token here unfortunately. |
Beta Was this translation helpful? Give feedback.
The right way to do you is to actually check if the name is 'nameof'. It's not a special keyword.
In terms of roslyn quoter, it needs to call 'ParseToken' to get the right token here unfortunately.