AnyKey support and service key injection#1475
Merged
Conversation
This does not yet compile but should serve as a starting point for figuring out how to make AnyKey work.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1475 +/- ##
===========================================
+ Coverage 77.98% 78.57% +0.59%
===========================================
Files 211 216 +5
Lines 5414 5611 +197
Branches 1150 1207 +57
===========================================
+ Hits 4222 4409 +187
- Misses 692 695 +3
- Partials 500 507 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tillig
commented
Feb 12, 2026
Member
Author
tillig
left a comment
There was a problem hiding this comment.
I've reviewed and iterated over this, verifying that the performance impact is negligible at best, and all the new tests pass. I'm going to call this good so I can see what it will take to update A.E.DI using the new functionality.
This was referenced Mar 13, 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.
Resolves #1471.
Adds two primary features that allow for improved support for .NET 10:
AnyKey: Microsoft.Extensions.DependencyInjection added the concept ofAnyKeyback in .NET 8, but the behavior of that became far more complex in .NET 10. For example,AnyKeyitems no longer get returned when resolving collections ofAnyKey- they only get returned in individual resolution calls. This madeAnyKeymuch more complex than simply "matching any key," necessitating a more integrated solution with core Autofac.[ServiceKey]attribute it uses to inject the service key into an object. With native support forAnyKeythis seemed like a valuable feature to also bring into Autofac.This should all be backwards-compatible with existing Autofac keyed services - it's just new API to support these new features. It should also make the Autofac.Extensions.DependencyInjection layer a bit easier to implement since we can map the Microsoft
AnyKeyto the AutofacAnyKeyand it should "just work."While working in here I did a couple of one-click optimizations to remove unused usings and similar minor housekeeping things. That increased the size of the PR but seemed not-unreasonable.