Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the SyntaxToken.Kind in current version of Roslyn?

Tags:

c#

roslyn

I'm trying to update a project which makes heavy use of comparison against SyntaxToken.Kind. This property appears to have disappeared in newer versions of Roslyn and I wondered if there an alternative method or an extension method I could write to get the same functionality?

The code has many references such as:

if (expression.OperatorToken.Kind == SyntaxKind.PlusEqualsToken)

Any ideas?

like image 646
Christopher Cook Avatar asked May 05 '14 03:05

Christopher Cook


1 Answers

Add a using for Microsoft.CodeAnalysis.CSharp.Syntax, and then use the CSharpKind() extension method.

like image 146
Kevin Pilch Avatar answered Nov 15 '22 01:11

Kevin Pilch