You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DI scope disposal (#7205) part 2: scope-resolved services are externally owned, not disposed again by the object tracker #7382
Part 2 of #7205, split from #7328. Its branch issue-7205-di-scope-dispose (head b1a2ba27d2) has commits to reuse.
Scope
When a disposable DI scope is disposed (part 1), the object tracker also disposes the services the scope resolved. So each service is disposed twice, and a root singleton that another source shares is disposed too early. Make the scope the only owner of what it resolves.
ObjectTracker.MarkExternallyOwned (internal). DependencyInjectionDataSourceAttribute marks what Create returns as externally owned only when the scope is disposable. Document that contract in Create's XML docs.
ObjectGraphDiscoverer: IAsyncInitializer objects reached through the properties of an externally owned service, at any depth, are still initialized but not disposed by the tracker. Values of TUnit-injected data-source properties stay with the tracker.
An object counted by another source just before it was marked externally owned is released without being disposed (the race that ExternallyOwnedSingletonTests pins).
Files
src/TUnit.Core/Tracking/ObjectTracker.cs, src/TUnit.Core/Discovery/ObjectGraphDiscoverer.cs, src/TUnit.Core/Attributes/TestData/DependencyInjectionDataSourceSourceAttribute.cs, tests/TUnit.UnitTests/ExternallyOwnedSingletonTests.cs, and the _7205NonDisposableScopeTests and NestedScopeDependencyTests cases.
Acceptance criteria
Each scope-owned service is disposed exactly once, in both modes.
A non-disposable scope's services are still disposed by the tracker.
Activity
fix(core): leave DI scope-owned services to their owner (#7382)
fix(engine): preserve DI disposal ownership on failed rows (#7381, #7382
fix(engine): deliver row builder-context events to the test and raise…