-
-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Description
I'm using the newest version (Unity 5.11.10 single Container Nuget package) and ran into problems using ResolverOverride.
I want to update some Legacy code to the newest Unity Version (we're working currently with Version 5.8.13). As mentioned in other Issues, in order to get old behavior of passing Constructor Parameters to Resolve, I need that Legacy Extension. That works until Unity 5.11.6, then on later versions it won't work anymore (except I'm using .NET Framework 4, which I don't want to use).
To Reproduce
In this test case, the name of the TestClass shoul be "OverrideName", but it's "test".
public interface TestInteface
{
string name { get; }
}
public class TestClass : TestInteface
{
public string name { get; } = "test";
public TestClass()
{
}
public TestClass(string name)
{
this.name = name;
}
}
[TestClass]
public class RuntimeServiceTest
{
[TestMethod]
public void TestOverride()
{
var unityContainer = new UnityContainer();
unityContainer.AddExtension(new Legacy());
unityContainer.RegisterType<TestInteface, TestClass>();
var resolverOverride = new ResolverOverride[]
{
new ParameterOverride("name", "OverrideName")
};
var type = unityContainer.Resolve(typeof(TestInteface), resolverOverride);
Assert.AreEqual("OverrideName", ((TestClass)type).name);
}
}
Metadata
Metadata
Assignees
Labels
No labels