Repository navigation
v7.0.2
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
TrackInstanceandDispose()both accesseddisposableObjects(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 asInvalidOperationException: Collection was modifiedorArgumentException: 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— wrapsdisposableObjects.Add()inlock(container.lockObject), matching the locking pattern already used byScope.TrackInstance.ServiceContainer.Dispose()— atomically snapshots-and-clearsdisposableObjectsunderlockObject, then disposes the snapshot outside the lock so no lock is held during userDispose()calls (avoids deadlocks). A reference-equalityHashSetskips duplicate entries, consistent with howScope.Dispose()already works.DisposableObjectComparer— new private nested class usingRuntimeHelpers.GetHashCodefor 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)