unitycontainer / registration-by-convention

Unity.RegistrationByConvention package (Requires Core Implementation. Any contributors?)
Apache License 2.0
4 stars 12 forks source link

RegisterTypes extension ignoring 'overwriteExistingMappings' flag #5

Open BigPeeg opened 6 years ago

BigPeeg commented 6 years ago

If a type is registered in a Unity container where the interface and class follow the same pattern as used in 'registration by convention', when the RegisterTypes extension is used to register by convention, the original mapping is over-written despite the 'overwriteExistingMappings' flag of the extension method being set to 'false'.

`

        var container = new UnityContainer();
        container.RegisterType<IAppTester, AppTester>(new PerThreadLifetimeManager());

        container.RegisterTypes(
            AllClasses.FromLoadedAssemblies(),
            WithMappings.FromMatchingInterface,
            WithName.Default);

        container.Registrations.First(r => r.RegisteredType.Equals(typeof(IAppTester))).LifetimeManager.GetType().Should().Be<PerThreadLifetimeManager>("specifically registered type should remain");

`

ENikS commented 5 years ago

I would need a unit test to reproduce the error