Skip to content

Latest commit

 

History

History
54 lines (38 loc) · 882 Bytes

RCS9001.md

File metadata and controls

54 lines (38 loc) · 882 Bytes

RCS9001: Use pattern matching

Property Value
Id RCS9001
Severity Hidden

Examples

Code with Diagnostic

if (syntaxNode.IsKind(SyntaxKind.IdentifierName)) // RCS9001
{
    var identifierName = (IdentifierNameSyntax)syntaxNode;
}

Code with Fix

if (syntaxNode is IdentifierNameSyntax identifierName)
{
}

Code with Diagnostic

if (!syntaxNode.IsKind(SyntaxKind.IdentifierName)) // RCS9001
{
    return;
}

var identifierName = (IdentifierNameSyntax)syntaxNode;

Code with Fix

if (!(syntaxNode is IdentifierNameSyntax identifierName))
{
  return;
}

Applies to

(Generated with DotMarkdown)