aspnet / DependencyInjection

[Archived] Contains common DI abstractions that ASP.NET Core and Entity Framework Core use. Project moved to https://github.com/aspnet/Extensions
Apache License 2.0
873 stars 318 forks source link

Make lifetime a callsite property and add stackguards #638

Closed pakrym closed 5 years ago

pakrym commented 6 years ago

Changing cache key from Tuple<CallSite, Type> allows us:

  1. To create callsites non-atomically
  2. Remove the global lock in call site factory
  3. Add a stack guard that dispatched instead of throwing SO
  4. Emit key directly in IL instead of passing reference through

The cache key is changed to (type, slot) pair where type is service type and slot is an index of the item in case it was resolved in IEnumerable<Type>

Additional changes:

  1. Removed create instance call site - it's just a subset of ConstructorCallSite
muratg commented 5 years ago

Any impact on user code (i.e. is it a breaking change for users?)

pakrym commented 5 years ago

No

muratg commented 5 years ago

@pakrym could you either merge or close this? @natemcmaster is going to move this to the mondo repo and moving PRs are tricky. Thanks.