dotnet / roslyn-analyzers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RS1034 is not reported if type is not exactly `SyntaxNode`

carlreinke opened this issue · comments

Analyzer

Diagnostic ID: RS1034: Prefer 'IsKind' for checking syntax kinds

Analyzer source

NuGet Package: Microsoft.CodeAnalysis.Analyzers

Version: 3.3.4

Describe the bug

RS1034 is not reported if type is not exactly SyntaxNode.

Steps To Reproduce

ExpressionSyntax node = null!;
bool noWarning = node.Kind() == SyntaxKind.NullLiteralExpression;
bool warning = ((SyntaxNode)node).Kind() == SyntaxKind.NullLiteralExpression;

Expected behavior

RS1034 is reported on both instances of Kind() in example above.

Actual behavior

RS1034 is only reported on the second instance of Kind() in example above.