Repository navigation
Fix mapped key attribute precedence (#122) - #125
Conversation
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
|
Implemented in draft PR #125, against current develop The mapped activator retained both key attributes as independent flags and always considered ServiceKey first. Thus The fix caches one additional metadata flag describing the attribute order. A shared predicate applies that order consistently during constructor selection and argument resolution. A preceding FromKeyedServices binding wins when its effective key is non-null, even when its dependency is missing; normal availability/default rules then apply. An explicit null lookup does not prevent a later ServiceKey from injecting a non-null owning key. Inherited keys are evaluated against the actual request, and null/unkeyed contexts still ignore ServiceKey. Named value/key overrides remain first and bypass unselected attribute binding and owning-key type checks. Contextual decorators use the same corrected metadata. This is a small change within the existing cached activator. It adds no service lookups, validation provider, graph planner or private DI API access. Attribute inspection uses public reflection when the existing weak type-metadata cache is populated, and effective keys remain resolution-specific. The fix does not change the native original-type activator or bring in the deferred #121 implementation. README and the vNext changelog are updated. Verification:
CI for the exact final commit Work stops for review of PR #125 before another issue. #121/PR #124 remain on hold. After this fix is reviewed and merged, a release-validation checkpoint should explicitly acknowledge deferred #121; passing checks here do not establish full native graph-planning parity. No merge, tag, release-branch push, package publication or release action was performed. |
Adding an unrelated nonempty DependsOn map changed
[FromKeyedServices("fixed"), ServiceKey]from the explicitly keyed dependency to the owning service key. Preserve native DI's attribute order for untouched parameters, while keeping named overrides first.Fixes #122. Parameter metadata now caches whether FromKeyedServices precedes ServiceKey. A shared predicate selects the first effective non-null key binding during both constructor selection and argument resolution, including inherited/null keys. Contextual decorators reuse the corrected metadata. The change adds no service resolutions, graph validator or private DI API access; attribute inspection remains in the existing weak metadata cache. README and the vNext changelog document the behavior.
Verification on Windows with Microsoft DI 10.0.0:
dependencyversusblueon both current develop and published 0.8.0 across all four targets.ContinuousIntegrationBuild=Truepassed. An initial build hit reused-worker access errors; a fresh-worker build passed. Initial fixture/nullable warnings were corrected. Final build: zero errors or compiler/analyzer warnings, with only the two existing net472 package-support warnings from Microsoft.Extensions.Telemetry.Abstractions and Microsoft.Extensions.Diagnostics.Testing 10.0.0.CI for the exact final commit
94af8ba1eaadedb39a4075ea8c9eb5dbe547541fpassed: run 37932581363. Windows restore/build, all 10,960 tests and the four native DI hot-cache probes passed; only the same two net472 package-support warnings appeared. Pack and Publish were skipped.Draft for review; stop here until explicit continuation. #121 and PR #124 remain on hold. After review/merge, a release-validation checkpoint should explicitly acknowledge deferred #121; this PR does not establish full native graph-planning parity. No release actions are included.
Co-authored-by: Codex codex@openai.com