You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a transient service (which has openResolutionScope set) gets resolved using a factory-func from inside another service which has Reuse.Singleton set, then this resolve won't open a new scope as I would expected.
Is this behavior the desired behavior and I am just using it wrong?
[TestFixture]classTransient_resolve_with_scope_using_factory_func_in_singleton{[Test]publicvoidExample(){varcontainer=newContainer(rules =>rules.WithTrackingDisposableTransients());container.Register<Bar>(Reuse.Singleton);// if "Reuse.Singleton" gets removed, the scope ist opened (and injected as part of IResolverContext) as expected.container.Register<IFoo,Foo>(setup:Setup.With(openResolutionScope:true));container.Register<Dependency>(Reuse.ScopedTo<IFoo>());varbar=container.Resolve<Bar>();bar.DoStuffWithFoo();}classBar{privatereadonlyFunc<IFoo>fooFactory;privateIFoofoo;publicvoidDoStuffWithFoo(){foo=fooFactory();// expecting this to open a scope.foo.Dispose();}publicBar(Func<IFoo>fooFactory){this.fooFactory=fooFactory;}}interfaceIFoo:IDisposable{DependencyDep{get;}}classFoo:IFoo{publicDependencyDep{get;}privatereadonlyIResolverContext_scope;publicFoo(Dependencydep,IResolverContextscope){Dep=dep;_scope=scope;Assert.IsTrue(scope.CurrentScope!=null,"Expected to have a scope.");}publicvoidDispose()=>_scope.Dispose();}classDependency:IDisposable{publicboolIsDisposed{get;privateset;}publicvoidDispose()=>IsDisposed=true;}}
Used DryIoc-Version: 5.1.0
The text was updated successfully, but these errors were encountered:
When a transient service (which has openResolutionScope set) gets resolved using a factory-func from inside another service which has Reuse.Singleton set, then this resolve won't open a new scope as I would expected.
Is this behavior the desired behavior and I am just using it wrong?
Used DryIoc-Version: 5.1.0
The text was updated successfully, but these errors were encountered: