Skip to content
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

Use Dazinator.Extensions.DependencyInjection.ChildContainers #75

Open
dazinator opened this issue Sep 23, 2020 · 1 comment
Open

Use Dazinator.Extensions.DependencyInjection.ChildContainers #75

dazinator opened this issue Sep 23, 2020 · 1 comment

Comments

@dazinator
Copy link
Owner

Autofac and Structuremap are "non native" DI containers.

I now have a solution to create child containers using the native Microsoft ServiceProvider: https://github.com/dazinator/Dazinator.Extensions.DependencyInjection/blob/develop/src/DependencyInjection.ChildContainers/README.md

I'll need to make this the "default" approach used, and possibly deprecate autofac and structuremap until they can be added back in future (if its too much work to tackle at this stage)

This will help solve a number of issues a bugs like #74

I was also never truly happy with the resolution of #38 because it involved creating a temporary "copy" of services that needed to be present in the child IServiceCollection when building the child container otherwise AddXyz() calls that look for those services and sometimes grab instances, could fail. The new approach solves that thanks to ChildServiceCollection: https://github.com/dazinator/Dazinator.Extensions.DependencyInjection/blob/develop/src/DependencyInjection.Tests/ChildServiceProvider/ChildServiceCollectionTests.cs

@dazinator
Copy link
Owner Author

I've updated to the latest version of Dazinator.Extensions.DependencyInjection.ChildContainers as part of the feature branch to update to dotnet6.

I've not tested fully that the updated package hasn't broken anything - I am using a class "ChildServiceCollection" from that package to filter the services added to the child container being built for autofac, however I think some stuff changed and I actually now need to build a child service provider as shown by that package, as part of the building a child service provider is that it knows how to delegate requests for things like parent open generic services, to the parent correctly.

So I will remove stucturemap and autofac, and change the child container implementation to be more suitable to this new approach as part of the .net 6 feature branch upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant