Name the expected rule in the tests that annotate diagnostics - #1355
Merged
Conversation
meziantou
enabled auto-merge (squash)
August 27, 2026 05:26
This was referenced Aug 27, 2026
Bump Meziantou.Analyzer from 3.0.139 to 3.0.189
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#556
Closed
Closed
Bump Meziantou.Analyzer from 3.0.139 to 3.0.189
Analogy-LogViewer/Analogy.AspNetCore.LogProvider#542
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
This was referenced Aug 31, 2026
Open
Open
Open
Open
Open
Open
Open
Open
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.
[|code|]says "a diagnostic is reported here" without saying which one. For an analyzer that supports a singlerule that is unambiguous, but 15 test files use it with an analyzer that reports several rules, so the tests never
checked that the rule that fires is the one under test.
EqualityShouldBeCorrectlyImplementedAnalyzerMA0077Testscould have been reporting MA0095 everywhere and still passed.
This replaces 125 of those annotations with the
{|ruleId:code|}syntax theProjectBuilderalready supports,naming the rule the test is about. 23 rules are covered: MA0023, MA0040, MA0075, MA0076, MA0077, MA0079, MA0092,
MA0093, MA0094, MA0095, MA0107, MA0114, MA0117, MA0122, MA0135, MA0139, MA0141, MA0146, MA0148, MA0149, MA0166,
MA0207 and MA0208.
The
[|code|]annotations of the tests whose analyzer supports a single rule are left alone: there is nothing todisambiguate there.
UsePatternMatchingForEqualityComparisonsAnalyzerTestsalso loses four$prefixes on interpolated strings thatinterpolate nothing. They had to go for
{|to be valid in the code under test, and the fixed code of the sametests follows for consistency.
No production code is touched, and no test is added or removed.
Verification
Meziantou.Analyzer.Test.roslyn5.9: 3840 tests, 0 failures.