I have two different Flowing Scopes, but they are returning the same instance of a scoped dependency.
To Reproduce
var container = new Container();
container.Options.DefaultScopedLifestyle = ScopedLifestyle.Flowing;
container.Register<Singleton>(Lifestyle.Singleton);
container.Register<Scoped>(Lifestyle.Scoped);
container.GetInstance<Singleton>();
public class Scoped { }
public class Singleton
{
public Singleton(Container c)
{
var scope1 = new Scope(c);
var scope2 = new Scope(c);
if (object.ReferenceEquals(scope1.GetInstance<Scoped>(), scope2.GetInstance<Scoped>()))
{
Assert.Fail("Resolved the same instance.");
}
}
}
In this example the Assert.Fail is being hit. I do not believe this is expected.
Additional context
- Adding
container.Options.EnableAutoVerification = false; fixes the problem.
- Running against latest version, 5.4.1