Skip to content

Remove repo-wide analyzer relaxation and honor test cancellation#418

Merged
ptr727 merged 1 commit into
developfrom
conformance/remove-broad-analyzer-suppressions
Jul 18, 2026
Merged

Remove repo-wide analyzer relaxation and honor test cancellation#418
ptr727 merged 1 commit into
developfrom
conformance/remove-broad-analyzer-suppressions

Conversation

@ptr727

@ptr727 ptr727 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Follow-up to the conformance audit for #387 (finding 1, analyzer suppression hygiene).

What prompted this

CODESTYLE.md "Analyzer Suppressions" names dotnet_analyzer_diagnostic.severity as the exact anti-pattern it forbids -- relaxing a batch of rules repo-wide -- yet the root .editorconfig carried it.

What removing it surfaced

Exactly one rule, and none of it in shipping code:

Rule Sites Project
xUnit1051 29 UtilitiesTests

Utilities and Sandbox produced zero findings under AnalysisLevel=latest-all + AnalysisMode=All. I re-ran with -p:EnforceCodeStyleInBuild=true to confirm IDE analyzers were not being silently skipped -- same result. The relaxation was hiding nothing in library code.

xUnit1051 is a true positive, not a suppression candidate: it asks that async calls in tests pass TestContext.Current.CancellationToken so xUnit v3 can cancel a stalled test. The clearest case is DownloadAsyncTests, which makes real network calls and previously had no cancellation path if a request hung.

Audit of every other suppression

Each was removed and rebuilt independently to prove it is load-bearing. All of them are -- kept, no changes:

Suppression Scope Fires when removed Verdict
CA1711 Utilities yes Deliberate Ex suffix convention
CA1707 UtilitiesTests yes xUnit Method_Scenario_Expected naming
CA1515 UtilitiesTests yes xUnit needs public test classes
NoWarn IL3058 Utilities, Sandbox yes (10 under PublishAot=true) Polly/Serilog not annotated AOT-compatible; no source location to scope
IDE0055 root no Inert today, but CSharpier owns formatting; kept as a guard, now with a rationale comment

The naming-rule severities were also raised to warning as a probe and produced nothing.

Verification

  • dotnet build -c Release with TreatWarningsAsErrors intact: 0 warnings, 0 errors
  • dotnet test -c Release: 183/183 passed
  • dotnet format style --verify-no-changes: clean
  • CSharpier + dotnet format Husky hooks passed on commit

Notes

No Closes #387 here -- per AGENTS.md "Branching Model", closing keywords belong in the develop -> main promotion PR. #387's other three findings (inline pragmas, GlobalUsings.cs, stale package source) were already resolved in earlier work and need no change.

A fleet-wide issue is being filed against ProjectTemplate, since LanguageTags carries the identical dotnet_analyzer_diagnostic line and the other repos have not been probed.

CODESTYLE "Analyzer Suppressions" forbids relaxing a batch of rules
repo-wide, and names dotnet_analyzer_diagnostic.severity as the exact
anti-pattern. Removing it surfaced one rule, xUnit1051, across 29 call
sites in the test project; the library and Sandbox were already clean
under AnalysisLevel=latest-all with no findings behind the relaxation.

Pass TestContext.Current.CancellationToken at each site so xUnit v3 can
cancel a stalled test. This matters most in the network-bound Download
tests, where a hung request previously had no cancellation path.

Every remaining suppression was re-verified as load-bearing by removing
it and rebuilding: CA1711 (Ex suffix), CA1707 and CA1515 (xUnit naming
and visibility), and the IL3058 NoWarn (Polly and Serilog are not
annotated AOT-compatible, and IL3058 has no source location to scope).
IDE0055 stays because CSharpier owns formatting; it now carries that
rationale as a comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 18, 2026 16:27
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.89%. Comparing base (281b96c) to head (16e3211).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #418   +/-   ##
========================================
  Coverage    66.89%   66.89%           
========================================
  Files           13       13           
  Lines         1160     1160           
  Branches       108      108           
========================================
  Hits           776      776           
  Misses         338      338           
  Partials        46       46           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

This PR tightens analyzer suppression hygiene by removing a repo-wide analyzer relaxation from the root .editorconfig, and updates async tests to pass TestContext.Current.CancellationToken so xUnit v3 can cancel stalled tests.

Changes:

  • Remove dotnet_analyzer_diagnostic.severity relaxation from the root .editorconfig (keep IDE0055 suppression with rationale).
  • Plumb TestContext.Current.CancellationToken into async calls across UtilitiesTests (Download/FileEx/HttpClient/StringCompression/Extensions tests).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
UtilitiesTests/StringCompressionAsyncTests.cs Passes xUnit cancellation token into async compression/decompression calls.
UtilitiesTests/HttpClientFactoryResilienceTests.cs Passes xUnit cancellation token into HttpClient.GetAsync calls.
UtilitiesTests/FileExAsyncTests.cs Passes xUnit cancellation token into FileEx and File.*Async calls (but contains one argument-order compile issue).
UtilitiesTests/ExtensionsTests.cs Passes xUnit cancellation token into async string extension calls.
UtilitiesTests/DownloadAsyncTests.cs Passes xUnit cancellation token into Download.*Async calls.
.editorconfig Removes repo-wide analyzer relaxation and documents why IDE0055 is suppressed.

Comment thread UtilitiesTests/FileExAsyncTests.cs
@ptr727
ptr727 merged commit ad8013c into develop Jul 18, 2026
12 checks passed
@ptr727
ptr727 deleted the conformance/remove-broad-analyzer-suppressions branch July 18, 2026 16:37
@ptr727 ptr727 mentioned this pull request Jul 18, 2026
ptr727 added a commit that referenced this pull request Jul 18, 2026
Promotion of the current `develop` integration state to `main`.

## Contents

| Area | Change |
| --- | --- |
| Analyzer conformance | #418 -- removed the repo-wide
`dotnet_analyzer_diagnostic` relaxation, fixed the 29 `xUnit1051` sites
it hid |
| Docs | #419 -- Codecov coverage shield in the README build status
block |
| Repo config | #417 -- repo-config carry refresh and self-audit carry |

## Conformance issues resolved

Closes #380
Closes #387

#380 (xUnit v3 + AwesomeAssertions, `ILoggerFactory` seam) was already
satisfied in the tree -- verified rather than assumed: 0 `Assert.*`
remaining against 245 `.Should()` calls, `xunit.v3` 3.2.2 pinned with no
v2 package, zero Serilog references in the library, and
`Utilities/LogOptions.cs` matching the LanguageTags reference seam.

#387's four findings were likewise already addressed except finding 1
(analyzer suppression hygiene), which #418 closes. Every remaining
suppression was independently probed by removing it and rebuilding, and
all proved load-bearing (`CA1711`, `CA1707`, `CA1515`, `NoWarn IL3058`).

## Release impact: no auto-publish

This promotion carries **no shipped input**. Per
[WORKFLOW.md](../blob/main/WORKFLOW.md) the inclusion list is
`Utilities/**`, `version.json`, `Directory.Build.props`,
`Directory.Packages.props`; this diff is confined to tests, docs, CI,
and repo config:

```
.editorconfig  .github/workflows/merge-bot-pull-request.yml  AUDIT.md  README.md
UtilitiesTests/*.cs  repo-config/*  spec/secrets.json
```

`Utilities/**` is byte-identical between `main` and `develop`, so the
published package is already current and merging this will correctly
**not** trigger a stable release.
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