container
container copied to clipboard
UnityContainer defaults for internal constructor with more params over a public default one
Container defaults to internal constructor with more parameters over a public default constructor, Expected behavior is that the public empty constructor should be used; i.e. internal constructor should be treated as private? The following test fails.
[Test]
public void TestCtrSelection()
{
var uc = new UnityContainer();
uc.RegisterType<Service>();
uc.Resolve<Service>();
}
class CoreLogic
{
}
class Service
{
public CoreLogic Logic { get; private set; }
internal Service(CoreLogic cl)
{
Logic = cl;
Assert.Fail("Defaulted to internal ctr");
}
public Service()
{
Logic = new CoreLogic();
Assert.Pass();
}
}
In Unity v6 it will be possible to change set of members (public, private, internal) included in selection.
@ENikS is there any workaround for version 5 which can be used for a third-party library that uses IServiceCollection only and a service to be resolved is an internal class?
not really