-
-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Labels
Milestone
Description
InjectionMember parameters are ignored in mappings
Type mappings establish relations between implementation and registration types. For example, instances could be registered by base types or interfaces they implement.
Mappings could build their own pipelines or just map to some other types. In case when custom pipeline is required, injection members are used to specify how it should be created.
Always build registrations with InjectionMember parameters
When any injection members are associated with registration, the mapping should never redirect to other registrations, instead it should create its own pipeline and resolve using that pipeline.
To Reproduce
Note the non default InjectionConstructor in type registration:
[TestMethod]
public void Always_Build_If_Injected()
{
var instance = new Service<object>();
// Arrange
Container.RegisterType(typeof(IService<>), typeof(Service<>), new InjectionConstructor(typeof(object)))
.RegisterInstance(instance);
// Act
var value = Container.Resolve<IService<object>>();
// Validate
Assert.IsNotNull(value);
// Should never be the same
Assert.AreNotSame(instance, value);
}