Replace test #pragma suppressions with SuppressMessage and null-forgiving#184
Merged
Conversation
…ving CODESTYLE.md now bans `#pragma warning disable` in favor of [SuppressMessage] / .editorconfig. Conform the two test cases: - CA1508 (analyzer): annotate OperatorEquals_BothNull_ReturnsTrue with [SuppressMessage] + Justification - the test intentionally compares two null tags to exercise operator== with both operands null. - CS8602 (compiler nullable; [SuppressMessage] cannot suppress it): use the null-forgiving operator on the Equals(object?) receiver instead. Build: 0 warnings / 0 errors. Tests: 257/257 pass.
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns the test suite with the newly consolidated CODESTYLE.md rule (post template re-sync) that bans #pragma warning disable by replacing pragma-based suppressions with [SuppressMessage] (for analyzer warnings) and code-based nullability handling (for compiler warnings).
Changes:
- Replace
#pragma warning disable CS8602inEquals_NullTag_ReturnsFalseby using the null-forgiving operator on the call site. - Replace
#pragma warning disable CA1508inOperatorEquals_BothNull_ReturnsTruewith a method-level[SuppressMessage]including a justification.
Copilot read tag! as redundant. It is load-bearing: removing it reintroduces CS8602 (verified by a clean build), because the compiler flags the Equals(object?) overload's receiver as possibly-null here - a false-positive that [SuppressMessage] cannot suppress (CS#### are compiler, not analyzer, diagnostics). Add a one-line comment so the suppression reads intentionally rather than as a real null concern.
ptr727
added a commit
that referenced
this pull request
Jun 22, 2026
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.
Follow-up to the template re-sync (#182):
CODESTYLE.mdnow bans#pragma warning disablein favor of[SuppressMessage]/.editorconfig. Two test cases inLanguageTagTests.csused#pragma; this conforms them to the rule. Surfaced by Copilot on #183.Changes
OperatorEquals_BothNull_ReturnsTruewith[SuppressMessage]+Justification. The test deliberately compares two null tags to exerciseoperator==with both operands null.[SuppressMessage]cannot suppress compilerCS####diagnostics, only#pragma/NoWarnor code can. Replaced the#pragmawith the null-forgiving operator on theEquals(object?)receiver - idiomatic and rule-compliant (CODESTYLE bans#pragma, not!).No
#pragma warningdirectives remain in the codebase.Verification
dotnet build(no-incremental): 0 warnings / 0 errorsdotnet format style --verify-no-changes: cleandotnet test: 257/257 pass