Add FAQ based on immutable container challenges
With Autofac 5 we removed ContainerBuilder.Update and containers are now immutable.
We should add an FAQ based on this discussion issue to help people understand alternatives to updating the container proper.
Also, we should make sure there aren't anymore doc references to ContainerBuilder.Update.
This may tie into #99 if the Update() removal is the root issue there?
This issue is more specifically to write a new article to explain how to work with immutable containers. I'll leave the other issue open so this one can be separately tracked.
How can I add a registration to the global scope after build?
@StefanoVuerich; typically questions like that should be asked on Stack Overflow, rather than added as comments on existing issues.
That being said, the short answer is that, after Autofac 5.0, you cannot modify the global scope after it has been built. Child lifetime scopes can continue to have custom registrations within that scope. See https://autofaccn.readthedocs.io/en/latest/best-practices/#consider-a-container-as-immutable for some more detail.
@alistairjevans After googling a bit found that PreserveExistingDefaults works. It it really the best solution to force people add a kind of "place holder object", that can be later on overrided? Wouldn't be simpler to let the container have the possibility to add a new registration?
I'd recommend reading the content at the beginning of this thread for an explanation as to why it isn't simpler to allow a container update.
Placeholder objects aren't your only option; you can use delegate registrations, or organise your child scopes so you can change the dependencies per-scope.