Change Log
v7.1.0 (05/21/2026)
Full Changelog
Merged Pull Requests
Align keyed service tests with MS.DI spec and fix AnyKey enumeration (05/21/2026) #613 (seesharper)
Summary
- Aligns
KeyedMicrosoftTests.cswith the upstreamKeyedDependencyInjectionSpecificationTests.csfrom dotnet/runtime - Fixes a bug where AnyKey (
"*") registrations were incorrectly included inIEnumerable<T>keyed service resolution - Bumps version to 7.1.0
Changes
Tests (KeyedMicrosoftTests.cs)
- Updated
ResolveKeyedServicesAnyKeyWithAnyKeyRegistration: expects 4 services (not 5); AnyKey registrations are excluded from enumeration - Updated
ResolveKeyedServicesSingletonInstanceWithAnyKey: AnyKey registrations are not included when listing services by a specific key - Updated
ResolveKeyedSingletonFromScopeServiceProviderandResolveKeyedScopedFromScopeServiceProvider: added assertions that direct AnyKey lookup throws - Added 13 new tests:
CombinationalRegistration,ResolveKeyedServicesAnyKeyConsistency,ResolveKeyedServicesAnyKeyConsistencyWithAnyKeyRegistration,ResolveKeyedServicesAnyKeyOrdering,ResolveWithAnyKeyQuery_Constructor,ResolveWithAnyKeyQuery_Constructor_Duplicates,ResolveWithAnyKeyQuery_InstanceProvided,ResolveWithAnyKeyQuery_InstanceProvided_Duplicates,ResolveRequiredKeyedServiceThrowsIfNotFound,SimpleServiceKeyedResolution
Fix (LightInject.cs)
In CreateEmitMethodForEnumerableServiceServiceRequest, two cases fixed (both variance and no-variance branches):
GetKeyedServices(AnyKey): added&& k.ServiceName != "*"so the"*"registration itself is not returnedGetKeyedServices("some-key"): removed|| k.ServiceName == "*"so AnyKey wildcard registrations don't appear in specific-key enumerations
Single-service resolution with AnyKey wildcard fallback is unaffected.
Test plan
- All 1561 tests pass
🤖 Generated with Claude Code