-
-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
The AnyConcreteTypeNotAlreadyRegisteredSource throws an exception when tries to Resolve unregistered Meta<T> types #495
Comments
This appears to affect all generated relationship sources - An ideal solution would not hardcode all the relationships in ACTNARS but would instead somehow not provide stuff that's already provided. Hmmm. |
It's almost like the registration lookup process needs to behave like an event, like when a lookup takes place in a registration source, not only would you return a (potentially empty) list of registrations, but also something to indicate "stop processing, it's been handled." That way the I'll have to think about how to deal with that. In the meantime, I'll add the unit test (skipped for now) to the repo so we can work through it. |
OK, I think I figured it out. For generic types we need to not only check to see if the whole generic is registered, but also see if we can handle the thing in the generic. I'm working through tests now. That said, I think the bottom test will still fail: [Test]
public void Test3()
{
var builder = new ContainerBuilder();
builder.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());
var container = builder.Build();
var meta = container.Resolve<IEnumerable<Meta<ILogAppender>>>();
Assert.AreEqual(1, meta.Count());
} If no Here's a test I have passing with the updated code: [Fact]
public void DoesNotInterfereWithMetadata()
{
// Issue #495: Meta<T> not correctly handled with ACTNARS.
var cb = new ContainerBuilder();
cb.RegisterType<RegisteredType>().WithMetadata("value", 1);
cb.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());
var container = cb.Build();
var regType = container.Resolve<Meta<RegisteredType>>();
Assert.Equal(1, regType.Metadata["value"]);
var nonRegType = container.Resolve<Meta<NotRegisteredType>>();
Assert.False(nonRegType.Metadata.ContainsKey("value"));
var interfaceMeta = container.Resolve<IEnumerable<Meta<IInterfaceType>>>();
Assert.Equal(0, interfaceMeta.Count());
var classMeta = container.Resolve<IEnumerable<Meta<NotRegisteredType>>>();
Assert.Equal(1, classMeta.Count());
} |
The fix for this is in v4.2.0-354 on the MyGet feed and will eventually be pushed to NuGet as 4.2.0. |
Cool! Thanks for the fix! |
Published as 4.2.0 to NuGet. |
If the
AnyConcreteTypeNotAlreadyRegisteredSource
is used then resolving any non registered Meta types throws an exception.Here is some testcases demonstating the problem
The thrid test throws the following exeption
See this question on SO for more context : http://stackoverflow.com/questions/21743262/autofac-mvc-5-registerwebapifilterprovider-causes-unresolveable-ioverridefilter
The text was updated successfully, but these errors were encountered: