Skip to content

v7.1.0

Latest

Choose a tag to compare

@seesharper seesharper released this 21 May 12:46
2fd3438

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.cs with the upstream KeyedDependencyInjectionSpecificationTests.cs from dotnet/runtime
  • Fixes a bug where AnyKey ("*") registrations were incorrectly included in IEnumerable<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 ResolveKeyedSingletonFromScopeServiceProvider and ResolveKeyedScopedFromScopeServiceProvider: 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 returned
  • GetKeyedServices("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