JasperFx / lamar

Fast Inversion of Control Tool and Successor to StructureMap
https://jasperfx.github.io/lamar
MIT License
563 stars 118 forks source link

Why is transient lifetime applied to the inner instance when decorators are applied ? #262

Closed paziz001 closed 3 years ago

paziz001 commented 3 years ago

I am using a custom decorator policy and I've noticed that the lifetime of the instance I am trying to decorate always changes to transient. This happens when the decorators are applied here. https://github.com/JasperFx/lamar/blob/master/src/Lamar/ServiceFamily.cs#L76

jeremydmiller commented 3 years ago

@paziz001 I honestly don't remember exactly why I had to do that, but I'd guess that it was to make the dependency be completely inlined to the decorator. You're effectively the lifecycle of the decorator instance at that point.

Does this actually matter?

paziz001 commented 3 years ago

I had an issue with some scoped instances that would be decorated and then would change to transient. But the actual issue was somewhere else actually so you can close this. Thanks :)

jeremydmiller commented 3 years ago

Gotcha.