Skip to content

Invalid torn lifestyle when registering collections conditionally #1010

@dotnetjunkie

Description

@dotnetjunkie

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions