Skip to content

Reduce analyzer warning backlog across tests and targeted src#403

Merged
mpaulosky merged 16 commits into
devfrom
squad/402-reduce-analyzer-warning-backlog
May 28, 2026
Merged

Reduce analyzer warning backlog across tests and targeted src#403
mpaulosky merged 16 commits into
devfrom
squad/402-reduce-analyzer-warning-backlog

Conversation

@mpaulosky

@mpaulosky mpaulosky commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Broaden the analyzer cleanup work on this branch into a single tracked delivery covering validated warning reductions across multiple test projects plus targeted production-code fixes in src/AppHost and src/Web.

What changed

  • Reduced analyzer warnings across:
    • tests/AppHost.Tests/*
    • tests/Web.Tests/*
    • tests/Web.Tests.Bunit/*
    • tests/Web.Tests.Integration/*
    • tests/Architecture.Tests/*
  • Applied targeted production-side cleanup in:
    • src/AppHost/AppHost.cs
    • src/AppHost/Properties/AssemblyInfo.cs
    • src/Web/Components/Theme/ThemeProvider.razor.cs
    • src/Web/Data/MongoDbBlogPostRepository.cs
    • src/Web/Data/MongoDbCategoryRepository.cs
    • src/Web/Infrastructure/FileStorage/LocalDiskFileStorage.cs
    • src/Web/Security/RoleClaimsHelper.cs
  • Reworked the AppHost theme reload/bootstrap coverage so the seeded toggle test uses a shared trustworthy-readiness contract instead of a blanket skip.
  • Removed the earlier local-only .squad/* and .vscode/settings.json artifacts from the PR surface.
  • Addressed the substantive Copilot follow-up comments by restoring the RoleClaimsHelper readability fix, moving ThemeToggleTestRuntime into its own file, restoring the more idiomatic AppHost HTTP client setup, and adding focused LocalDiskFileStorage coverage.

Validation

  • dotnet format MyBlog.slnx --verify-no-changes
  • dotnet build MyBlog.slnx --configuration Release
  • dotnet test tests/Architecture.Tests/Architecture.Tests.csproj --configuration Release --no-build
  • dotnet test tests/Domain.Tests/Domain.Tests.csproj --configuration Release --no-build
  • dotnet test tests/Web.Tests/Web.Tests.csproj --configuration Release --no-build
  • dotnet test tests/Web.Tests.Bunit/Web.Tests.Bunit.csproj --configuration Release --no-build
  • dotnet test tests/Web.Tests.Integration/Web.Tests.Integration.csproj --configuration Release --no-build
  • dotnet test tests/AppHost.Tests/AppHost.Tests.csproj --configuration Release --no-build

Review notes

  • The earlier Copilot comments about .squad/* and .vscode/settings.json were against the original draft surface and are now resolved.
  • The PR is no longer draft-blocked by local-only artifacts.
  • Codecov still reports 5 uncovered changed lines in src/Web/Infrastructure/FileStorage/LocalDiskFileStorage.cs, despite the added focused test coverage.

Closes #402

mpaulosky and others added 2 commits May 27, 2026 22:16
- MongoClient disposals via 'using' directive in AppHost integration tests
- HttpClientHandler refactoring in MongoSeedDataIntegrationTests
- Pass-through fake cache services in handler tests (no NSubstitute seams)
- Test class sealing and Dispose expansion for CA1001 compliance
- StringComparison.Ordinal in RazorSmokeTests for CA1307 compliance
- NavMenuTests button access refactored away from LINQ Last() on IReadOnlyList
- Zero warnings in Release build across entire solution

Closes #402

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- MongoDbFixture: use MongoDbBuilder("mongo") to avoid obsolete parameterless ctor
- RedisFixture: use RedisBuilder("redis") to avoid obsolete parameterless ctor
- EnvVarTests: migrate GetEnvironmentVariableValuesAsync → ExecutionConfigurationBuilder
  API per Aspire 13.x guidance; update assertions to work with
  IEnumerable<KeyValuePair<string,string>> returned by resolvedConfig.EnvironmentVariables

All #pragma warning disable CS0618 blocks removed from tests/.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the squad Squad triage inbox — Lead will assign to a member label May 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ PR Added to Squad Triage Queue

This PR has been labeled with squad and added to the triage queue.

Next steps:

  • The squad Lead will review and assign to an appropriate team member
  • A squad:member label will be added after triage

If you know which squad member should handle this, you can add the appropriate squad:member label yourself.

@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Test Results Summary

556 tests  +2   556 ✅ +3   39s ⏱️ +9s
  6 suites ±0     0 💤  - 1 
  6 files   ±0     0 ❌ ±0 

Results for commit 5b44269. ± Comparison against base commit b331753.

This pull request removes 1 and adds 3 tests. Note that renamed tests count towards both.
AppHost.Tests.Tests.Layout.LayoutThemeToggleTests ‑ ThemeToggle ClickingSwitchesBrightnessAndHtmlDarkClass
AppHost.Tests.Tests.Layout.LayoutThemeToggleTests ‑ ThemeToggle ClickingSwitchesBrightnessAndHtmlDarkClass(initialBrightness: "dark", initialHasDarkClass: True)
AppHost.Tests.Tests.Layout.LayoutThemeToggleTests ‑ ThemeToggle ClickingSwitchesBrightnessAndHtmlDarkClass(initialBrightness: "light", initialHasDarkClass: False)
Web.Infrastructure.FileStorage.LocalDiskFileStorageTests ‑ AddFileAsync WithAllowedImage WritesFileUnderUploadsAndReturnsStoredName

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.49%. Comparing base (b331753) to head (e16d384).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #403      +/-   ##
==========================================
+ Coverage   86.05%   87.49%   +1.43%     
==========================================
  Files          71       71              
  Lines        1750     1775      +25     
  Branches      214      214              
==========================================
+ Hits         1506     1553      +47     
+ Misses        165      145      -20     
+ Partials       79       77       -2     
Files with missing lines Coverage Δ
src/Web/Components/Theme/ThemeProvider.razor.cs 86.04% <100.00%> (+4.79%) ⬆️
src/Web/Data/MongoDbBlogPostRepository.cs 100.00% <100.00%> (ø)
src/Web/Data/MongoDbCategoryRepository.cs 100.00% <100.00%> (ø)
...Infrastructure/FileStorage/LocalDiskFileStorage.cs 70.83% <100.00%> (+70.83%) ⬆️
src/Web/Security/RoleClaimsHelper.cs 91.93% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mpaulosky mpaulosky marked this pull request as ready for review May 28, 2026 20:07
Copilot AI review requested due to automatic review settings May 28, 2026 20:07

Copilot AI left a comment

Copy link
Copy Markdown

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 completes a broad analyzer-warning cleanup across multiple test projects (AppHost.Tests, Web.Tests, Web.Tests.Bunit, Web.Tests.Integration, Architecture.Tests) and targeted production files in src/AppHost and src/Web. Highlights include removing #pragma CS0618 blocks by migrating to Testcontainers 4.12 image-string constructors and the Aspire 13.x ExecutionConfigurationBuilder, replacing NSubstitute ValueTask setups with file-local fakes, adding ConfigureAwait(false) and a deferred-state-update pattern to ThemeProvider, scoping EF Core DbContext disposal with explicit ConfigureAwait(false), and converting the seeded reload/bootstrap theme-toggle AppHost test from a static skip to the shared readiness contract.

Changes:

  • Test-project cleanup: new AssemblyInfo.cs files (CLSCompliant(false)), local fake cache services, scoped NoWarn updates (CA1014/CA1711), and bUnit StringComparison.Ordinal / index-based IReadOnlyList access fixes.
  • Production cleanup: ConfigureAwait(false) and await using reshaping in Mongo repositories, ThemeProvider, and LocalDiskFileStorage; Program made internal; CA1865-style change in RoleClaimsHelper.
  • AppHost test rework: shared ThemeToggleTestRuntime helper now used by both LayoutThemeToggleTests and ThemeToggleInteractionTests; static skip removed from seeded reload test.
  • Local-only artifacts (.vscode/settings.json, .squad/*) included in the diff per PR draft note.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.vscode/settings.json Adds user-specific absolute paths; not intended for merge.
.squad/** Squad agent history, decisions, identity updates; PR notes these are local-only.
src/AppHost/AppHost.cs Program made internal (covered by InternalsVisibleTo AppHost.Tests).
src/AppHost/Properties/AssemblyInfo.cs New repo-standard header + CLSCompliant(false).
src/Web/Components/Theme/ThemeProvider.razor.cs Adds ConfigureAwait(false), suppresses CA1515 for Razor discovery, defers state updates until after JS calls.
src/Web/Data/MongoDbBlogPostRepository.cs Restructures await using to allow explicit ConfigureAwait(false) on disposal.
src/Web/Data/MongoDbCategoryRepository.cs Same disposal pattern change as above.
src/Web/Infrastructure/FileStorage/LocalDiskFileStorage.cs Replaces await using var with try/finally + DisposeAsync().ConfigureAwait(false).
src/Web/Security/RoleClaimsHelper.cs Replaces StartsWith("[") with direct indexer check.
tests/AppHost.Tests/EnvVarTests.cs Migrates obsolete API to ExecutionConfigurationBuilder.
tests/AppHost.Tests/MongoSeedDataIntegrationTests.cs Adds using to MongoClient; restructures HttpClientHandler/HttpClient construction.
tests/AppHost.Tests/MongoShowStatsIntegrationTests.cs Replaces disposable SemaphoreSlim start gate with TaskCompletionSource; adds using to MongoClient.
tests/AppHost.Tests/Tests/Layout/LayoutThemeToggleTests.cs Removes static skip; reuses shared readiness helpers.
tests/AppHost.Tests/Tests/Layout/ThemeToggleInteractionTests.cs Extracts helpers into ThemeToggleTestRuntime shared with LayoutThemeToggleTests.
tests/Architecture.Tests/* Adds StringComparison.Ordinal; expands NoWarn to include CA1014.
tests/Web.Tests.Bunit/* Adds SetVoidResult(), StringComparison.Ordinal, index-based IReadOnlyList access, CA1812 suppression, expands NoWarn.
tests/Web.Tests.Integration/* Testcontainers 4.12 builder migration; new AssemblyInfo.cs; expands NoWarn.
tests/Web.Tests/Handlers/*.cs Replaces NSubstitute ValueTask setups with file-local fakes; uses specific inner exception types.
tests/Web.Tests/Infrastructure/Caching/*.cs Marks classes sealed; expands Dispose to block body.
tests/Web.Tests/Properties/AssemblyInfo.cs New repo-standard header + CLSCompliant(false).

Comment thread .vscode/settings.json Outdated
Comment thread .squad/decisions.md Outdated
Comment thread src/Web/Security/RoleClaimsHelper.cs Outdated
Comment thread tests/AppHost.Tests/MongoSeedDataIntegrationTests.cs Outdated
Comment thread tests/AppHost.Tests/Tests/Layout/ThemeToggleInteractionTests.cs Outdated
@mpaulosky mpaulosky force-pushed the squad/402-reduce-analyzer-warning-backlog branch from 7b95d6f to b24c97b Compare May 28, 2026 20:14
@mpaulosky mpaulosky enabled auto-merge (squash) May 28, 2026 21:39
@mpaulosky mpaulosky merged commit 8eb9b5d into dev May 28, 2026
15 checks passed
@mpaulosky mpaulosky deleted the squad/402-reduce-analyzer-warning-backlog branch May 28, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squad Squad triage inbox — Lead will assign to a member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Sprint 20] Reduce analyzer warning backlog

2 participants