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

Obsolete LifetimeScopeLifestyle is confusing #373

Closed
andycmaj opened this issue Feb 8, 2017 · 3 comments
Closed

Obsolete LifetimeScopeLifestyle is confusing #373

andycmaj opened this issue Feb 8, 2017 · 3 comments
Labels

Comments

@andycmaj
Copy link

andycmaj commented Feb 8, 2017

I'm seeing an obsolete warning when trying to use this lifestyle:

warning CS0618: 'LifetimeScopeLifestyle' is obsolete: 'This lifestyle is obsolete. Please use SimpleInjector.Lifestyles.ThreadScopedLifestyle instead.'

Using LifetimeScope based on this answer: https://stackoverflow.com/questions/39248736/with-lifestyle-to-use-for-console-application.

This is especially confusing when combined with this on the SimpleInjector documentation under the PerThread lifestyle:

This lifestyle is deliberately left out of Simple Injector because it is considered to be harmful. Instead of using Per Thread lifestyle, you will usually be better of using one of the Scoped lifestyles.

I'm thinking the documentation needs to be updated?
Could use some guidance on when to use various lifestyles.

@dotnetjunkie
Copy link
Collaborator

You are getting is warning because you are using an alpha version of Simple Injector v4. We don't have any documentation for v4 yet.

I do agree however that we should make the difference between the ThreadScopedLifestyle and a non-existing per-thread lifestyle clear in the v4 documentation.

@dotnetjunkie
Copy link
Collaborator

But the guidance is as follows: Simple Injector supports several scoped lifestyles and both Transient and Singleton. They are all safe for use. The built-in ThreadScopedLifestyle is completely different from the described per-thread lifestyle and doesn't have the same pitfalls and dangers as a per-thread lifestyle has. The ThreadScopedLifestyle (or LifetimeScopeLifestyle in v3) is safe to use.

@dotnetjunkie dotnetjunkie changed the title Obsolete LifetimeScopeLifestyle is confusing Obsolete LifetimeScopeLifestyle is confusing Feb 8, 2017
@dotnetjunkie
Copy link
Collaborator

I improved the documentation to make the difference between the Per-Thread and Thread-Scoped lifestyle more apparent.

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

2 participants