Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instances produced with RegisterFallback factory are being disposed on ServiceContainer.Dispose() #558

Open
dombrovsky opened this issue Sep 18, 2021 · 0 comments

Comments

@dombrovsky
Copy link

dombrovsky commented Sep 18, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant