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

CC0022 DI container delegate causes error #545

Closed
hmmdeif opened this issue Oct 9, 2015 · 1 comment
Closed

CC0022 DI container delegate causes error #545

hmmdeif opened this issue Oct 9, 2015 · 1 comment

Comments

@hmmdeif
Copy link

hmmdeif commented Oct 9, 2015

Using Simple Injector and lifestyle scoping (so it handles disposables inside the container) triggers CC0022 when the class is registered using a delegate:

container.Register<IDisposableIntr>(() => new DisposableImpl(), Lifestyle.Scoped);

This causes CC0022 to encounter an error and get disabled since it can't generate a solution. The warning is fine and I can disable it with a pragma declaration, but I figured the error probably shouldn't occur!

@giggio
Copy link
Member

giggio commented Oct 16, 2015

Bug confirmed. Here is a simple test case that is library independent:

class Container
{
    static void Foo()
    {
        var container = new Container();
        container.Register<System.IO.MemoryStream>(() => new System.IO.MemoryStream());
    }
    void Register<T>(System.Func<T> f) { }
}

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

No branches or pull requests

2 participants