Skip to content

UnityContainer defaults for internal constructor with more params over a public default one #279

@hawayel

Description

@hawayel

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();
 }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions