test: validate the DI container to catch captive-dependency regressions - #57
Merged
Merged
Conversation
Extract Control Menu's service registrations from Program.cs into an AddControlMenuServices extension so a test can build the real container with ValidateScopes + ValidateOnBuild. This catches captive dependencies (a Singleton consuming a scoped service) at test time instead of at the first dotnet run -- the class of bug that shipped in v1.2.0 when IImageService/ITracingService were registered Singleton against the scoped IDependencyPathResolver and aborted Dev startup (exit 82), invisible to 444 green tests + CI because nothing ever built the Program.cs container. Adds DependencyInjectionValidationTests: one test builds the real container and asserts no validation error; a second proves the validation options actually detect the captive-dependency shape. Program.cs behavior is unchanged -- it just calls the extension.
bilbospocketses
enabled auto-merge (squash)
June 12, 2026 19:02
bilbospocketses
added a commit
that referenced
this pull request
Jun 24, 2026
… vendored icons (#76) * docs(plan): audit MINOR mop-up + follow-ups (5-PR batch) * fix(frontend): audit MINOR cleanup #42-#47 + #57 - #43 define semantic --*-bg / --*-text theme tokens (light + dark); dark mode now resolves real values instead of silently using the light-mode fallback - #44 dedup byte-identical .dialog/.modal CSS; theme-aware pill :hover via color-mix - #45 re-key scrcpy settings modal to app theme tokens (was unset Bootstrap --bs-*); the modal now follows light/dark instead of always-dark fallbacks - #46 fix stale "conic" comment (the code is four linear gradients) - #47 home-tiles.js batches reads then writes (no per-card layout thrash); remove dead .home-module-* CSS from the reverted tile experiment - #42 subnets.html Close-tab link no longer traps a non-script-opened tab - #57 vendor bootstrap-icons 1.11.3 (CSS + woff2/woff) under wwwroot/lib; drop the jsDelivr CDN dependency (works offline, closes the no-SRI gap)
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.
What
Pulls Control Menu's service registrations out of
Program.csinto anAddControlMenuServices(this IServiceCollection, IDataPathResolver)extension, and adds a test that builds the real container withValidateScopes+ValidateOnBuildturned on.Why
The v1.2.0 imaging captive-dependency bug (fixed in #56) shipped past 444 green tests and CI because nothing ever built the
Program.cscontainer.IImageService/ITracingServicewere registeredSingletonwhile depending on the scopedIDependencyPathResolver-- a captive dependency that abortsdotnet runin Development (exit 82) viaValidateOnBuild. bUnit assembles its own minimal service collections, and the packaged app runs Production where scope validation is off, so both blind spots lined up.This closes the gap: the registrations now live behind one testable seam, and
DependencyInjectionValidationTestsbuilds them under full validation.Program.csbehavior is unchanged -- it just calls the extension.Tests
AddControlMenuServices_BuildsWithFullValidation_DoesNotThrow-- builds the real graph; fails on any captive dependency or missing registration.BuildServiceProvider_WithFullValidation_CatchesCaptiveDependency-- guards the guard: proves the validation options actually detect a singleton-consuming-scoped capture, so the first test cannot silently rot if someone weakens the options.Confirmed it bites: temporarily flipping
IImageServiceback toSingletonmakes the first test fail with exactly "Cannot consume scoped service 'IDependencyPathResolver' from singleton 'IImageService'" -- the original bug. Reverted; full suite green at 446.