Christopher Cook
Christopher Cook

Reputation: 830

How to get the SyntaxToken.Kind in current version of 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?

Upvotes: 5

Views: 1040

Answers (1)

Kevin Pilch
Kevin Pilch

Reputation: 11605

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

Upvotes: 7

Related Questions