Add RCS9012: Call IsKind instead of comparing Kind - #1820
Open
josefpihrt wants to merge 6 commits into
Open
Conversation
Ship a CodeAnalysis analyzer (Info by default, Warning in-repo) that rewrites Kind() ==/!= SyntaxKind to Microsoft's single-parameter IsKind. Co-authored-by: Cursor <cursoragent@cursor.com>
josefpihrt
commented
Aug 15, 2026
josefpihrt
commented
Aug 15, 2026
josefpihrt
commented
Aug 15, 2026
josefpihrt
commented
Aug 15, 2026
josefpihrt
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review
Bugbot found no bugs. Manual review:
Must fix
- pre_build / RCS0039 — test class base list must be on one line (inline comment).
Suggestions
- Code fix: guard
IsKindExpressionInfo.Successbefore rewriting. - Document / follow up: no coverage for
SyntaxToken/SyntaxTrivia.Kind()comparisons (common in this repo). .editorconfigwarning is forward-looking until the CodeAnalysis.Analyzers package pin is bumped.
Otherwise the analyzer/fix shape looks solid (single + || chains, constant SyntaxKind only, Microsoft single-param IsKind only).
josefpihrt
commented
Aug 15, 2026
josefpihrt
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review
Bugbot found no bugs. Manual review:
Must fix
- pre_build / RCS0039 — test class base list must be on one line (inline comment).
Suggestions
- Code fix: guard
IsKindExpressionInfo.Successbefore rewriting. - Document / follow up: no coverage for
SyntaxToken/SyntaxTrivia.Kind()comparisons (common in this repo). .editorconfigwarning is forward-looking until the CodeAnalysis.Analyzers package pin is bumped.
Otherwise the analyzer/fix shape looks solid (single + || chains, constant SyntaxKind only, Microsoft single-param IsKind only).
Put the test class base list on one line for RCS0039, and bail out when IsKindExpressionInfo parsing fails in the code fix. Co-authored-by: Cursor <cursoragent@cursor.com>
Recognize Microsoft Kind/IsKind extensions for Token, Trivia, and NodeOrToken so IsKindExpressionInfo and RCS9012 cover those receivers. Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Author
|
Included Token/Trivia coverage in this PR: |
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UseIsKindInsteadOfKindComparison) toRoslynator.CodeAnalysis.Analyzerswith code fix and tests..editorconfigsets warning.Kind() ==/!=(and?.Kind()), including same-receiver||chains → chained MicrosoftIsKind(not Roslynator multi-param overloads).Fixes #1819
Test plan
dotnet testfilterFullyQualifiedName~RCS9012(8 tests)Kind() ==andKind() == A || Kind() == BMade with Cursor