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

Invalid torn lifestyle when registering collections conditionally #1010

Open
dotnetjunkie opened this issue Dec 3, 2024 · 0 comments
Open
Labels
Milestone

Comments

@dotnetjunkie
Copy link
Collaborator

Describe the bug

When two collections are registered conditionally, it triggers a Torn Lifestyle validation, while the configuration is valid.

To Reproduce

var container = new Container();

var reg1 = container.Collection.CreateRegistration<ILogger>(typeof(NullLogger));
var reg2 = container.Collection.CreateRegistration<ILogger>(typeof(ConsoleLogger));

container.RegisterConditional(
    serviceType: typeof(IEnumerable<ILogger>),
    registration: reg1,
    c => c.Consumer?.ImplementationType == typeof(Consumer1));

container.RegisterConditional(
    serviceType: typeof(IEnumerable<ILogger>),
    registration: reg2,
    c => c.Consumer?.ImplementationType != typeof(Consumer1));

container.Verify();

Additional context

Latest release v5.5.0

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

No branches or pull requests

1 participant