Instances produced with RegisterFallback factory are being disposed on ServiceContainer.Dispose()
dombrovsky opened this issue · 0 comments
dombrovsky commented
class SomeDisposableClass : IDisposable
{
public void Dispose() { }
}
var disposableInstance = new SomeDisposableClass();
_serviceContainer.RegisterFallback((serviceType, serviceName) => serviceType == typeof(SomeDisposableClass), request => disposableInstance);
_serviceContainer.Dispose();
In this example SomeDisposableClass instance would be disposed when LightInject container disposed. However it was not LightInject container who created the instance, so it should not be responsible for calling IDisposable.Dispose on it.
May be related to #538.