Skip to main content

RCS9008: Call 'Last' instead of using []

Properties

PropertyValue
Default SeverityInfo
Minimum language version-

Examples

Example #1

diagnostic.cs
syntaxList[syntaxList.Count - 1]
fix.cs
syntaxList.Last()

Remarks

This analyzer is applicable for following types:

  • Microsoft.CodeAnalysis.ChildSyntaxList
  • Microsoft.CodeAnalysis.SeparatedSyntaxList<TNode>
  • Microsoft.CodeAnalysis.SyntaxList<TNode>
  • Microsoft.CodeAnalysis.SyntaxNodeOrTokenList
  • Microsoft.CodeAnalysis.SyntaxTokenList
  • Microsoft.CodeAnalysis.SyntaxTriviaList

Applies to