Reduce analyzer warning backlog across tests and targeted src#403
Conversation
- 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>
🏗️ PR Added to Squad Triage QueueThis PR has been labeled with Next steps:
|
Test Results Summary556 tests +2 556 ✅ +3 39s ⏱️ +9s 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.♻️ This comment has been updated with latest results. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
…hods and remove unnecessary skips
…rmance warning in TestAuthorizationService
…or concurrency exceptions and refactor cache service
…parison in type checks
…sure proper disposal of FileStream
…csproj for clarity
There was a problem hiding this comment.
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.csfiles (CLSCompliant(false)), local fake cache services, scopedNoWarnupdates (CA1014/CA1711), and bUnitStringComparison.Ordinal/ index-basedIReadOnlyListaccess fixes. - Production cleanup:
ConfigureAwait(false)andawait usingreshaping in Mongo repositories,ThemeProvider, andLocalDiskFileStorage;Programmadeinternal;CA1865-style change inRoleClaimsHelper. - AppHost test rework: shared
ThemeToggleTestRuntimehelper now used by bothLayoutThemeToggleTestsandThemeToggleInteractionTests; 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). |
7b95d6f to
b24c97b
Compare
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/AppHostandsrc/Web.What changed
tests/AppHost.Tests/*tests/Web.Tests/*tests/Web.Tests.Bunit/*tests/Web.Tests.Integration/*tests/Architecture.Tests/*src/AppHost/AppHost.cssrc/AppHost/Properties/AssemblyInfo.cssrc/Web/Components/Theme/ThemeProvider.razor.cssrc/Web/Data/MongoDbBlogPostRepository.cssrc/Web/Data/MongoDbCategoryRepository.cssrc/Web/Infrastructure/FileStorage/LocalDiskFileStorage.cssrc/Web/Security/RoleClaimsHelper.cs.squad/*and.vscode/settings.jsonartifacts from the PR surface.RoleClaimsHelperreadability fix, movingThemeToggleTestRuntimeinto its own file, restoring the more idiomatic AppHost HTTP client setup, and adding focusedLocalDiskFileStoragecoverage.Validation
dotnet format MyBlog.slnx --verify-no-changesdotnet build MyBlog.slnx --configuration Releasedotnet test tests/Architecture.Tests/Architecture.Tests.csproj --configuration Release --no-builddotnet test tests/Domain.Tests/Domain.Tests.csproj --configuration Release --no-builddotnet test tests/Web.Tests/Web.Tests.csproj --configuration Release --no-builddotnet test tests/Web.Tests.Bunit/Web.Tests.Bunit.csproj --configuration Release --no-builddotnet test tests/Web.Tests.Integration/Web.Tests.Integration.csproj --configuration Release --no-builddotnet test tests/AppHost.Tests/AppHost.Tests.csproj --configuration Release --no-buildReview notes
.squad/*and.vscode/settings.jsonwere against the original draft surface and are now resolved.src/Web/Infrastructure/FileStorage/LocalDiskFileStorage.cs, despite the added focused test coverage.Closes #402