-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
Nested scope doesn't see new registrations in parent scope #608
Comments
By and large, scopes, once created are immutable. The Update method is kind of a hack to get things into a single scope, but generally it's truly just a hack. When you create a child scope, the parent's registry gets copied over into the child. Updating the parent doesn't update the copy with the child. I'll mark this as an enhancement. There are some other internal things we want to fix and this would go along with those, possibly even being fixed as a byproduct of fixing the other issues. |
This isn't something that I have ever run into before. Do you have an example of a situation where this has been required? |
I think we're going to close this as "won't fix." Scopes, generally speaking, are immutable once you create them and updating a container out from under a scope will actually cause more problems than it solves - for example, you may have already resolved something from the child scope that is incorrect now based on changes made in the parent scope after the resolution takes place. Instead, I'd recommend looking at ways to get around actually modifying the parent scope and hoping the child scope sees new parent registrations post-creation. In general, I'd say best practice is to really try to treat containers as immutable. |
It appears [Nancy bootstrapping] uses I guess I'll open this back up to see if we need to do something here, though I still feel this is a "won't fix." I'd just as soon remove the "Update" method to avoid the challenges/inconsistencies it causes in various behaviors like |
Re-closing as won't fix. Nancy has an issue to handle removal of their use of |
Changes to the parent component registry don't propagate well to the nested registry when the service in the nested registry is already initialized.
Steps to reproduce
Create parent and nested scopes. Make nested scope to create it's own registry.
Make nested scope to initialize service registration info for some service:
Update parent scope and try to resolve updated service implementation from nested scope
Expected output
Updated implementation gets resolved from nested scope.
Aсtual output
Autofac.Core.Registration.ComponentNotRegisteredException : The requested service 'System.String' has not been registered.
The text was updated successfully, but these errors were encountered: