RCS9001: Use pattern matching
Properties
Property | Value |
---|---|
Default Severity | Hidden |
Minimum language version | - |
Examples
Example #1
diagnostic.cs
if (syntaxNode.IsKind(SyntaxKind.IdentifierName))
{
var identifierName = (IdentifierNameSyntax)syntaxNode;
}
fix.cs
if (syntaxNode is IdentifierNameSyntax identifierName)
{
}
Example #2
diagnostic.cs
if (!syntaxNode.IsKind(SyntaxKind.IdentifierName))
{
return;
}
var identifierName = (IdentifierNameSyntax)syntaxNode;
fix.cs
if (!(syntaxNode is IdentifierNameSyntax identifierName))
{
return;
}