-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Child container doesn't dispose all its resolved components on disposal #324
Comments
Thanks for the very quick response! I couldn't figure it out myself as an outsider due to the complex nature of the project. Will try out the fix when a new version is released. |
@reijerh - No problem. Once @jonorossi reviews the PR and we clean it up a little we will get this deployed for you. |
The problem here is that that component is only indirectly resolved via the child container, the component is registered, resolved, tracked and should be released in the parent container. I've added a review comment to #335, that fix will break many scenarios, unfortunately the fix for this won't be so easy, as you can see child containers haven't really been designed, they aren't really recommended in their current state because of many limitations. Windsor however has followed the rule that if you call Resolve you must also call Release even for transients, which would fix this unit test, but obviously not your expectations of Dispose. @reijerh could you share how you are using child containers because an |
Please join us on #338 for more discussion |
I commented regarding the use case in #338, should probably continue discussion there. |
@reijerh - I find it very interesting the way the discussion is going. I had a go at fixing your bug and I must agree with @jonorossi after he reviewed it. It is going to fix your problem and ruin the party for everyone else. This is why I want the damn thing removed! :) I have posted a way of achieving this without even using the parent/child container API Windsor. I really do not believe this API is needed and it conforms to your requirement of not polluting the parent container. In fact parents, do not need to know about child containers. Would love to hear some feedback from you on this approach. It does use releasetracking/burdens(something that was asked to be removed, not sure I agree just yet). The only difference is I did adhere to the resolve/release rule. You are not doing that. Doc update? Assuming you clearly inherited this app. Maybe we can materialise something useful in the way of a facility if you are open to collaborating on this. |
PS: My approach also fixes this bug :) |
More specifically: child containers don't seem to dispose components that were resolved through them, but were registered in the parent container.
Original issue: #27
It seems the core issue this ticket was about wasn't really fixed, at least the bug is still there in 4.0.
Here's a unit test (adopted from @mickdelaney's fork mickdelaney@7e8ab35):
Output:
(NB: the original unit test registered the component as Singleton, meaning the test would already fail at the first case)
It seems that if we register the
DisposableFoo
at thechildContainer
instead, the object is disposed correctly.You can see in the debugger that the object is tracked by the
parentContainer
rather than by thechildContainer
.The text was updated successfully, but these errors were encountered: