You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current implementation of ExternallyControlledLifetimeManager could be used for either:
registering external instance
registering type or factory
The container will return instance if it is present or, if already collected or never created, will attempt to create new instance. This behavior is incorrect.
In case of instance registration, it can only be used until collected by the GC. Once collected, container should throw an exception when instance is requested.
If type or factory is registered with this manager it should create new instance and use it until collected. Once collected it should recreate it and so on. (This scenario is useful in all kinds of cache scenarios)
The solution for this issue is to reserve ExternallyControlledLifetimeManager for instance registrations only and create a new manager WeakReferenceLifetimeManager to cover type and factory weak reference registrations.
Description
Current implementation of
ExternallyControlledLifetimeManager
could be used for either:The container will return instance if it is present or, if already collected or never created, will attempt to create new instance. This behavior is incorrect.
In case of instance registration, it can only be used until collected by the GC. Once collected, container should throw an exception when instance is requested.
If type or factory is registered with this manager it should create new instance and use it until collected. Once collected it should recreate it and so on. (This scenario is useful in all kinds of cache scenarios)
The solution for this issue is to reserve
ExternallyControlledLifetimeManager
for instance registrations only and create a new managerWeakReferenceLifetimeManager
to cover type and factory weak reference registrations.See Also
Issue unitycontainer/abstractions#114
The text was updated successfully, but these errors were encountered: