dadhi / DryIoc

DryIoc is fast, small, full-featured IoC Container for .NET
MIT License
1.03k stars 122 forks source link

[MS.DI] Use DryIoc sources directly for the DryIoc.Microsoft.DependencyInjection package #494

Open dadhi opened 2 years ago

dadhi commented 2 years ago

There are a number of problems with abstracting away from the DryIoc and keeping it as dependency:

  1. We have two IServiceProvider abstractions, the first is the DryIoc.Container itself and the second is the DryIocServiceProvider wrapper inside the MS.DI. The reason for the latter is that the same IServiceProvider object should implement the ISupportRequiredService from the Microsoft.Extensions.DependencyInjection.Abstractions. So either I depend on the MS.DI abstraction package in DryIoc (I don't want to) or I am doubling on the IServiceProvider implementation, complicating things.
  2. The second reason is the performance/memory, and is partially related to the first point. Having additional abstraction build for the MS.DI adapter just for the sake of wrapping things includes the performance cast or indirection and growing memory. Why do I need a separate object for IServiceProvider or for IServiceScopeFactory if this functionality is already implemented in Container. There is open question about the separate scope wrapped implementing a IServiceScope.

Pros:

Cons:

dadhi commented 2 years ago

//cc @davidfowl If you see that, what are your thoughts?