Skip to content

Name the expected rule in the tests that annotate diagnostics - #1355

Merged
meziantou merged 1 commit into
mainfrom
tests/annotate-expected-rule-ids
Aug 27, 2026
Merged

Name the expected rule in the tests that annotate diagnostics#1355
meziantou merged 1 commit into
mainfrom
tests/annotate-expected-rule-ids

Conversation

@meziantou

Copy link
Copy Markdown
Owner

[|code|] says "a diagnostic is reported here" without saying which one. For an analyzer that supports a single
rule 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. EqualityShouldBeCorrectlyImplementedAnalyzerMA0077Tests
could have been reporting MA0095 everywhere and still passed.

This replaces 125 of those annotations with the {|ruleId:code|} syntax the ProjectBuilder already 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 to
disambiguate there.

UsePatternMatchingForEqualityComparisonsAnalyzerTests also loses four $ prefixes on interpolated strings that
interpolate nothing. They had to go for {| to be valid in the code under test, and the fixed code of the same
tests 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.

@meziantou
meziantou enabled auto-merge (squash) August 27, 2026 05:26
@meziantou
meziantou merged commit fc00b7e into main Aug 27, 2026
13 checks passed
@meziantou
meziantou deleted the tests/annotate-expected-rule-ids branch August 27, 2026 05:31
This was referenced Aug 27, 2026
This was referenced Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant