Skip to content

Container lifestyle issues #12

@feugen24

Description

@feugen24

In the implementation code "AsyncScopedLifestyle" is used but in the docs example it is not

// Setup Simple Injector
var container = new Container();
container.Register<IWorkerService, WorkerService>();

//this code should be added like in unit tests (set lifestyle for scoped registrations)
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();

//and maybe even (default all registrations to scoped)
container.Options.DefaultLifestyle = new AsyncScopedLifestyle();

since the alternative would be to set .Register<...>(Lifestyle.Scoped) for all registrations. If this is not set they will default to transient.

Another point is to have at least one test to check .Dispose() is called. A typical scenario is to have a Entity framework DbContext registered and it should be disposed at the end of the scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions