Skip to content

Releases: seesharper/LightInject

v7.1.0

21 May 12:46
2fd3438

Choose a tag to compare

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

v7.0.2

19 May 12:27
f761eb7

Choose a tag to compare

Change Log

v7.0.2 (05/19/2026)

Full Changelog

Merged Pull Requests

Fixed issue #606: properly support named Lazy services (04/27/2025) #607 (kemsky)

Fixes issue #606.

I'm not entirely sure that all cases are covered, but tests passed and my issue is resolved.
Fix thread safety of disposableObjects in ServiceContainer.Dispose (05/19/2026) #611 (seesharper)

Summary

  • TrackInstance and Dispose() both accessed disposableObjects (List<IDisposable>) without any synchronization, creating a data race under concurrent load — most visibly when services are still being first-resolved on background threads while the container is being disposed. Depending on .NET version and timing, this manifests as InvalidOperationException: Collection was modified or ArgumentException: Destination array was not long enough.
  • Dispose() also had no guard against the same instance being disposed more than once (e.g. if two container lifetimes happened to return the same object).

Changes

  • TrackInstance — wraps disposableObjects.Add() in lock(container.lockObject), matching the locking pattern already used by Scope.TrackInstance.
  • ServiceContainer.Dispose() — atomically snapshots-and-clears disposableObjects under lockObject, then disposes the snapshot outside the lock so no lock is held during user Dispose() calls (avoids deadlocks). A reference-equality HashSet skips duplicate entries, consistent with how Scope.Dispose() already works.
  • DisposableObjectComparer — new private nested class using RuntimeHelpers.GetHashCode for stable object-identity hashing.
  • Dispose_ConcurrentWithServiceCreation_DoesNotThrow — stress test with 3 concurrent threads (2 resolving services, 1 disposing) over 1000 iterations as a regression guard.

Test plan

  • All 1529 existing tests continue to pass
  • New concurrent stress test passes under the fix

🤖 Generated with Claude Code
Bump version (05/19/2026) #612 (seesharper)

Closed Issues

  • Wrong using at LightInject.Source 7.0.0 nuget package (11/21/2024) #602 (nobyArdor)

v7.0.1

19 Nov 15:20
ce8ccbc

Choose a tag to compare

Change Log

v7.0.1 (11/19/2024)

Full Changelog

Merged Pull Requests

Removed unused usings (11/19/2024) #603 (seesharper)

Bump version (11/19/2024) #604 (seesharper)

Closed Issues

v7.0.0

06 Nov 23:27
818b50b

Choose a tag to compare

Change Log

v7.0.0 (11/06/2024)

Full Changelog

Merged Pull Requests

Master (08/12/2023) #591 (oliverscode)

Fix test code errors
Fix typo in readme.md (08/15/2023) #592 (tompazourek)

Added compatibility with Microsoft.Extensions.DependencyInjection for keyed services. (11/06/2024) #599 (seesharper)

This PR adds the EnableMicrosoftCompatibility option which makes LightInject compatible with Microsoft.Extensions.DependencyInjection.

This includes support for keyed services which is now part of Microsoft.Extensions.DependencyInjection
Use Net8 and bumped all deps (11/06/2024) #601 (seesharper)

Closed Issues

  • CanGetInstance throws System.ArgumentNullException when called with an unregistered serviceType and null serviceName (04/09/2024) #578 (mesakomarevich)

v6.6.4

08 May 21:37
db65698

Choose a tag to compare

Change Log

v6.6.4 (05/08/2023)

Full Changelog

Merged Pull Requests

Update LightInject.cs (01/01/2023) #584 (haavamoa)

Bugfix in GenericTypeMapper (05/08/2023) #588 (seesharper)

This PR fixes a bug that caused the GenericTypeMapper to return multiple candidates even if only one of the candidates actually implemented the requested service
Bump version number and dependencies (05/08/2023) #589 (seesharper)

Closed Issues

  • MissingMethodException - ASP.NET Core 2.1 Application Running Under .NET Full Framework (01/05/2023) #585 (bt-Knodel)

v6.6.3

31 Dec 19:48
3bde539

Choose a tag to compare

Change Log

v6.6.3 (12/31/2022)

Full Changelog

Merged Pull Requests

Call Completed handler on Dispose and DisposeAsync (12/31/2022) #583 (seesharper)

v6.6.2

29 Dec 23:58
13624c8

Choose a tag to compare

Change Log

v6.6.2 (12/29/2022)

Full Changelog

Merged Pull Requests

Added decorator test to prove that we can return without recorating (10/03/2022) #576 (seesharper)

Fixed issue #578 by setting serviceName to string.Empty if no registrations for the specified serviceType are found. (10/23/2022) #579 (mesakomarevich)

Fixed issue #578 and updated the unit tests that call CanGetInstance to cover null, empty, and whitespace values for the serviceName argument.
Bugfix dispose decorators as singleton (12/29/2022) #582 (seesharper)

Closed Issues

v6.6.1

19 Sep 22:47
78ac7b1

Choose a tag to compare

Change Log

v6.6.1 (09/19/2022)

Full Changelog

Merged Pull Requests

Only compile with asyncdisposable for netcoreapp3.1 and above (09/19/2022) #574 (seesharper)

This PR enables support for IAsyncDisposable ONLY for netcoreapp3.1 and above
Bumped to 6.6.1 (09/19/2022) #575 (seesharper)

Closed Issues

v6.6.0

19 Sep 13:04
373ccce

Choose a tag to compare

Change Log

v6.6.0 (09/12/2022)

Full Changelog

Merged Pull Requests

Disable nullable explicitly (09/12/2022) #572 (Pliner)

Hey,

We use LightInject(a source code package) as a built-in container for EasyNetQ.

We started a migration to Nullable Reference Types recently and observed build warnings because LightInject doesn't support them(and this is fine).

image

Could you consider adding #nullable disable pragma? It looks like the simplest way how these warnings could be suppressed.

Anyway, thanks for LightInject 🚀
Asyncdisposable (09/12/2022) #573 (seesharper)

This PR adds support for IAsyncDisposable

v6.5.2

09 Sep 15:07
26aac32

Choose a tag to compare

Change Log

v6.5.2 (09/09/2022)

Full Changelog

Merged Pull Requests

Use UnderlyingSystemType for MakeGenericMethod (09/09/2022) #571 (seesharper)

khellang/Scrutor#175