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

ACTNARS fails to resolve closed generics #855

Closed
droyad opened this issue Jun 19, 2017 · 2 comments
Closed

ACTNARS fails to resolve closed generics #855

droyad opened this issue Jun 19, 2017 · 2 comments
Labels

Comments

@droyad
Copy link

droyad commented Jun 19, 2017

We are using AnyConcreteTypeNotAlreadyRegisteredSource, and it's behaviour has changed in 4.2.0 due to this change stemming from #495.

For example we want to resolve Foo<Bar> where we have an implementation Foo<T>. The ACTNARS delegate is t => t.Name.StartsWith("Foo"). Foo<T> does not take Bar in the constructor.

ACTNARS currently (4.6.0) fails to resolve this type as it checks that Bar is registered (here

     [Fact]
        public void ConstructableOpenGenericsCanBeResolved()
        {
            var cb = new ContainerBuilder();
            cb.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource(t => t.Name.StartsWith("Progress")));
            var container = cb.Build();
            Assert.True(container.IsRegistered<Progress<Exception>>());
            Assert.NotNull(container.Resolve<Progress<Exception>>());
        }
@droyad droyad changed the title ACTNARS fails to resolve open generics ACTNARS fails to resolve closed generics Jun 19, 2017
@tillig
Copy link
Member

tillig commented Jun 19, 2017

Good find. We'll have to think about how best to solve this. AnyConcreteTypeNotRegisteredSource and ContravariantRegistrationSource are two great, flexible, pains in my behind. In #495 we found ACTNARS interfering with other registration sources but we really can't put special cases around Meta<T> or other source "known types." Maybe I fixed that wrong, or maybe there's more to check? Hmmm. Will have to dig in.

@tillig tillig added the bug label Jun 19, 2017
@alexmg alexmg closed this as completed in eb27003 Jul 9, 2017
@alexmg
Copy link
Member

alexmg commented Jul 25, 2017

This fix is included in 4.6.1 which has been pushed to NuGet.

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

No branches or pull requests

3 participants