-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
Discussion: Making container and scopes truly immutable after build #948
Comments
Sorry, looks like we never responded here. Yeah, this would be an interesting thing to figure out, but I think it'd be a pretty big change internally. It'd be interesting to see what it'd take. |
I'm willing to give this feature a try. There are two options to consider:
I prefer The power I have as a pre-contributor of this project are too limited to be able to make this decision on my own. Any input is appreciated. |
I don't have specific guidance on how to do this because as you've seen it's pretty big. Things I'd be thinking about, in no particular order, and maybe of varying value...
That's a lot, and like I said, it may or may not all be useful here, but it'd be stuff I'm keeping in the back of my head as I go. The registration API will likely have a sort of trickle-down effect as it changes the way things get registered... then get stored during resolution... and so on. |
This is going to be done in baby steps. I will update this list as the progress continues: Notes
Tasks
WIPhttps://github.com/weelink/Autofac/tree/feature/976_FixDuplicateTagsWhenBeginningLifetimeScope |
One of the benefits to have immutable It will most likely require to use some sort of immutable list, @tillig are you willing to take |
Could we simply ensure that the interfaces returned to public APIs are read-only like |
Exposing e.g. |
I've tried to turn
There is also a mutable dictionary in Some possible options:
I would like to have option 3, but the PR for this issue is already going to be big. |
Registrations may be immutable, but the properties should be mutable. Unclear if the properties need to be attached to the component registry or could come from somewhere else, but I don't have any suggestions for alternatives. |
…onFromComponentRegistryBuilder #948 Remove unnecessary locks during component registration
With the release of 5.0 containers are truly immutable after build. If there's additional work that should be done to this effect, please open a new issue with more specifics. Thanks! |
I really like that Autofac discourages from modifying built container/scope without creating a new scope but currently it can be easily circumvented (admittedly in a ugly way):
I haven't looked at how much effort it might take but would you consider tightening this in a such way so that
ComponentRegistry
cannot be modified directly?Two possible approaches I could think of on top of my head are to either make
ComponentRegistry
property or itsRegister*
methods internal. Obviously a breaking change but maybe something that can be marked as obsolete as get removed over time?The text was updated successfully, but these errors were encountered: