Repository navigation
Honor [FromKeyedServices] on handler constructor params (closes #3081) - #3086
Merged
Merged
Conversation
…loses #3081) JasperFx 2.9.10 fixes ConstructorFrame to resolve constructor parameters via the attribute-aware FindVariable(ParameterInfo) overload, so [FromKeyedServices] on a handler's constructor is honored (JasperFx/jasperfx#445). Before, keyed constructor parameters were resolved by type only and fell through to the default (last) registration — two keyed params of the same service type both bound to the same instance. - Bump JasperFx, JasperFx.Events, JasperFx.Events.SourceGenerator and JasperFx.SourceGenerator 2.8.2 -> 2.9.10 (RuntimeCompiler stays on its 5.x line). - Add keyed_services_on_handler_constructor: a handler whose constructor takes two [FromKeyedServices] params of the same service type, asserting each resolves to its own registration. Companion to using_with_keyed_services, which covers keyed services on Handle METHOD parameters (that path already worked). - Bump MessagePack 3.1.3 -> 3.1.7 to clear the NU1903 advisory that otherwise fails the build under TreatWarningsAsErrors. Closes #3081 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jeremydmiller
added a commit
that referenced
this pull request
Jun 12, 2026
Follow-up to #3086. The #3081 fix (JasperFx 2.9.10) lives in the shared codegen layer, so it applies to any container — but the issue was reported on Lamar, so add an explicit Lamar variant of the keyed-constructor-injection test. - Add Lamar.Microsoft.DependencyInjection to CoreTests (its transitive JasperFx unifies up to Wolverine's 2.9.10 — no version conflict). - keyed_services_on_handler_constructor now runs the same scenario against both the default container and Host.CreateDefaultBuilder().UseLamar(), sharing one helper, asserting each [FromKeyedServices] constructor parameter resolves to its own registration. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 15, 2026
This was referenced Jul 15, 2026
This was referenced Jul 24, 2026
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.
Follow-up to JasperFx/jasperfx#445, which fixed the root cause of #3081. This bumps Wolverine to the published fix and adds an end-to-end regression test.
Background
#3081: a handler with
[FromKeyedServices("…")]on its constructor parameters generated code that ignored the key — each keyed parameter was resolved by type only and fell through to the default (last) registration. With two keyed params of the same service type, both bound to the same instance (the reporter'snew TestRepo2()for both).Root cause was in JasperFx's
ConstructorFrame.FindVariables, which resolved constructor parameters via the type-onlyFindVariable(Type)overload instead of the attribute-awareFindVariable(ParameterInfo)overload thatMethodCallalready used. That asymmetry is exactly why keyed services on aHandle(...)method parameter already worked but the same attribute on the handler constructor did not. Fixed in JasperFx 2.9.10.Lamar's keyed resolution was already correct (verified directly in the Lamar repo — both at runtime and in its own generated build plan); the bug was container-agnostic, in the shared codegen layer.
Changes
JasperFx,JasperFx.Events,JasperFx.Events.SourceGenerator,JasperFx.SourceGenerator;JasperFx.RuntimeCompilerstays on its 5.x line).keyed_services_on_handler_constructor— a handler whose constructor takes two[FromKeyedServices]params of the same service type ("Test"→FirstRepo,"Test2"→SecondRepo); asserts each resolves to its own registration. Companion to the existingusing_with_keyed_services(method-parameter case).TreatWarningsAsErrors(affectsmaintoo; bundled here to keep this PR's CI green).Verification
using_with_keyed_services(4) still pass; 267 CoreTests green.wolverine.slnx -c Releasebuilds clean — 0 warnings, 0 errors.Note on Lamar
I did not add a Lamar-specific variant: Wolverine's test suite has no Lamar dependency, the bug reproduces identically on the default container (same
ConstructorFramecodegen path), and Lamar's keyed correctness is covered in the Lamar repo. Happy to wire up a Lamar test if preferred.🤖 Generated with Claude Code