A StackOverflowException is thrown when using flowing scoped lifestyle and registering a decorator that is injected inside a class which is injected as a collection. A bit hard to describe clearly but the steps to reproduce are simple (see below)
Behavior:
- Version 5.3.3: Works as expected
- Version 5.4.0 and up to latest (5.4.5): StackOverflowException
To reproduce:
internal class Program
{
static void Main()
{
var container = new Container();
container.Options.DefaultScopedLifestyle = ScopedLifestyle.Flowing;
container.Register<IStrategy, Strategy>();
container.RegisterDecorator<IStrategy, StrategyDecorator>();
container.Collection.Register<IMyInterface>(typeof(MyImpl));
container.Verify();
Console.WriteLine("All good");
Console.ReadLine();
}
}
public interface IMyInterface { }
public class MyImpl : IMyInterface
{
public MyImpl(IStrategy strategy) { }
}
public interface IStrategy { }
public class Strategy : IStrategy { }
public class StrategyDecorator : IStrategy
{
public StrategyDecorator(IStrategy strategy) { }
}
Additional context: