Obsolete LifetimeScopeLifestyle is confusing #373

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

Projects

None yet

2 participants

@andycmaj
andycmaj commented Feb 8, 2017 edited

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
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
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 from Obsolete `LifetimeScopeLifestyle` is confusing to Obsolete LifetimeScopeLifestyle is confusing Feb 8, 2017
@dotnetjunkie
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