Skip to content

Replace test #pragma suppressions with SuppressMessage and null-forgiving#184

Merged
ptr727 merged 2 commits into
developfrom
fix-test-pragma-suppressmessage
Jun 22, 2026
Merged

Replace test #pragma suppressions with SuppressMessage and null-forgiving#184
ptr727 merged 2 commits into
developfrom
fix-test-pragma-suppressmessage

Conversation

@ptr727

@ptr727 ptr727 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Follow-up to the template re-sync (#182): CODESTYLE.md now bans #pragma warning disable in favor of [SuppressMessage] / .editorconfig. Two test cases in LanguageTagTests.cs used #pragma; this conforms them to the rule. Surfaced by Copilot on #183.

Changes

  • CA1508 (analyzer - "'tag1 == tag2' is always true"): annotate OperatorEquals_BothNull_ReturnsTrue with [SuppressMessage] + Justification. The test deliberately compares two null tags to exercise operator== with both operands null.
  • CS8602 (compiler nullable warning): [SuppressMessage] cannot suppress compiler CS#### diagnostics, only #pragma/NoWarn or code can. Replaced the #pragma with the null-forgiving operator on the Equals(object?) receiver - idiomatic and rule-compliant (CODESTYLE bans #pragma, not !).

No #pragma warning directives remain in the codebase.

Verification

  • dotnet build (no-incremental): 0 warnings / 0 errors
  • dotnet format style --verify-no-changes: clean
  • dotnet test: 257/257 pass

…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.
Copilot AI review requested due to automatic review settings June 22, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CS8602 in Equals_NullTag_ReturnsFalse by using the null-forgiving operator on the call site.
  • Replace #pragma warning disable CA1508 in OperatorEquals_BothNull_ReturnsTrue with a method-level [SuppressMessage] including a justification.

Comment thread LanguageTagsTests/LanguageTagTests.cs
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@ptr727 ptr727 merged commit 0061702 into develop Jun 22, 2026
8 checks passed
@ptr727 ptr727 deleted the fix-test-pragma-suppressmessage branch June 22, 2026 17:53
ptr727 added a commit that referenced this pull request Jun 22, 2026
Maintenance promotion: template re-sync (#182) + test #pragma cleanup (#184). No functional change, no version.json bump.
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.

2 participants