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

Improve message of Lifestyle Mismatch diagnostic warning #63

Closed
dotnetjunkie opened this issue Jun 21, 2015 · 0 comments
Closed

Improve message of Lifestyle Mismatch diagnostic warning #63

dotnetjunkie opened this issue Jun 21, 2015 · 0 comments
Assignees
Milestone

Comments

@dotnetjunkie
Copy link
Collaborator

The following code:

container.Register<ServiceWithDependency<ILogger>>(Lifestyle.Singleton);
container.Register<ILogger, ConsoleLogger>(Lifestyle.Singleton);
container.RegisterDecorator<ILogger, LoggerDecorator>(Lifestyle.Transient);

container.GetInstance<ServiceWithDependency<ILogger>>();

Produces an exception with the following message:

ServiceWithDependency (Singleton) depends on ILogger (Transient).

Although technically correct, this message is really confusing for the user, because ILogger is registered as Singleton. So instead, the message should rather be something like this:

ServiceWithDependency (Singleton) depends on ILogger implemented by LoggerDecorator (Transient).

@dotnetjunkie dotnetjunkie added this to the Simple Injector v3.0 milestone Jun 21, 2015
@dotnetjunkie dotnetjunkie self-assigned this Jun 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant