Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegisterTypes extension ignoring 'overwriteExistingMappings' flag #5

Open
BigPeeg opened this issue Mar 9, 2018 · 1 comment
Open

Comments

@BigPeeg
Copy link

BigPeeg commented Mar 9, 2018

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
Copy link
Contributor

ENikS commented Aug 14, 2018

I would need a unit test to reproduce the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants