dadhi / DryIoc

DryIoc is fast, small, full-featured IoC Container for .NET
MIT License
988 stars 122 forks source link

Possible inconsistent behaviour #559

Closed dvabuzyarov closed 1 year ago

dvabuzyarov commented 1 year ago
 class Foo
        {
        }

        [TestMethod]
        public async Task ScopedServiceWithOpenResolutionScope()
        {
            var container = new Container();
            container.Register<Foo>(Reuse.Scoped, setup: Setup.With(openResolutionScope: true));
            var foo = container.Resolve<Foo>();
            Assert.IsNotNull(foo);
            var actual = container.Resolve<IEnumerable<Foo>>();
            Assert.AreEqual(1, actual.Count());
        }

the first resolve would be resolved normally, but container.Resolve<IEnumerable>() would return an empty collection. If we remove Reuse.Scoped from the registration then collection contains one item.

Not obvious why the collection is empty. And if it is a bug.

dadhi commented 1 year ago

@dvabuzyarov From the first glance looks like a bug. Thanks for finding and for the test. I will check.

dadhi commented 1 year ago

@dvabuzyarov The v5.3.4 containing the fix is out.