In Roslyn (Microsoft CodeAnalysis) how to create a logical literal?

Normally I would use SyntaxFactory, but I cannot figure out how to create a true or false node with it.

+5
source share
1 answer

I just figured it out. true and false are keywords, and I didn't have to deal with keywords, so I was looking for the wrong place. Keywords are likely to rely on their own syntactic index.

SyntaxFactory.LiteralExpression( SyntaxKind.TrueLiteralExpression ); 

After searching in the last hour, I finally remembered this tool. If anyone has a similar problem, which tool can help.

+9
source

All Articles