Open
Description
Description
When I use a ResolveAll with a generic interface before any named RegisterInstance, all subsequent ResolveAll always return an empty array.
To Reproduce
public interface IInterfaceA<T> { }
public class ClassA : IInterfaceA<object> { }
[TestMethod]
public void TestResolveAllWithGenericInterface()
{
var container = new UnityContainer();
var listBefore = container.ResolveAll<IInterfaceA<object>>(); // Commenting out this line makes the test pass
container.RegisterInstance<IInterfaceA<object>>("AName", new ClassA());
var listAfter = container.ResolveAll<IInterfaceA<object>>();
Assert.IsTrue(listAfter.Count() == 1); // Fails, listAfter is empty
}
Additional context
Commenting out the first ResolveAll makes the second one working as expected.
Using a regular interface (not generic) is working fine.
It seems the first ResolveAll register a bad plan in ArrayResolveStrategy.PreBuildUp method. GetFinalType() returns Object because no registration with IInstanceA<Object>
is found.
It was working fine in version 5.8.11.