dazinator / Dotnettency

Mutlitenancy for dotnet applications
MIT License
111 stars 23 forks source link

Method not found Autofac.ContainerBuilder.Update(Autofac.IContainer) #76

Open pippolino opened 3 years ago

pippolino commented 3 years ago

The method Autofac.ContainerBuilder.Update(Autofac.IContainer) has been removed from Autofac v5.0.0 with the message: "Containers should generally be considered immutable. Register all of your dependencies before building/resolving. If you need to change the contents of a container, you technically should rebuild the container. This method may be removed in a future major release."

// Update the root container with a service that can be used to build per tenant container!
ContainerBuilder updateBuilder = new ContainerBuilder();
var defaultServices = options.DefaultServices;
updateBuilder.RegisterInstance(new DelegateActionTenantContainerBuilder<TTenant>(defaultServices, adaptedContainer, configureTenant, containerEventsPublisher)).As<ITenantContainerBuilder<TTenant>>();
updateBuilder.Update(container); /**** HERE ****/

Is it possible to update the "Autofac" method in "ContainerBuilderOptionsExtensions" to be able to use newer versions of the Autofac library?

Thanks

dazinator commented 3 years ago

@pippolino thanks for getting in touch.

Yeah it's not great is it. To be honest, I have gone in a different direction recently with child containers. I am not sure what this means for this project yet suffice to say it's on hold for the time being in terms of me putting in any more time.

However I will consider PR's so if this is something you want to invest time in, I will consider merging a change to fix your scenario, but I won't be actively working on this repo for a time.

I am hoping that in the future, I'll bake in Microsoft.Extensions.DepenedencyInjection's native service provider as the default service provider to use for Child Containers, and I'll remove Autofac and Structuremap support, but allow those to be plugged in using a new mechanism. Until I have done work in other places to enable this, this project is effectively on hold.

dazinator commented 3 years ago

FYI: The child container implementation using ms's (slightly tweaked) native service provider is something I have up and running over here: https://github.com/dazinator/Dazinator.Extensions.DependencyInjection and at some point I expect to plug this in to dotnettency after I have done more scenario testing.