Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Roslyn (Microsoft CodeAnalysis) how do I create a boolean literal?

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

like image 992
R Esmond Avatar asked Jun 21 '16 23:06

R Esmond


1 Answers

I just figured it out. true and false are keywords and I haven't had to deal with keywords much so I was looking in the wrong spot. Keywords apparently tend to rely on having their own SyntaxKind.

SyntaxFactory.LiteralExpression( SyntaxKind.TrueLiteralExpression );

After searching for the last hour I finally remembered this tool. If anyone has a similar problem that tool might be able to help.

like image 107
R Esmond Avatar answered Oct 23 '22 04:10

R Esmond