Skip to content

Commit 24970cc

Browse files
committed
Merge branch 'master' of github.com:hadashiA/VContainer
2 parents 8bd35ff + 26248e6 commit 24970cc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

VContainer/Assets/VContainer/Runtime/Container.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public object Resolve(IRegistration registration)
6767
{
6868
return sharedInstances.GetOrAdd(registration, createInstance).Value;
6969
}
70-
return Parent.Resolve(registration);
70+
return (Parent.Parent is null ? Parent.Root : Parent).Resolve(registration);
7171

7272
case Lifetime.Scoped:
7373
var lazy = sharedInstances.GetOrAdd(registration, createInstance);

VContainer/Assets/VContainer/Tests/ScopedContainerTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ public void CreateScopeWithRegisterSingleton()
120120
{
121121
var parentSingleton = grandChildContainer.Resolve<NoDependencyServiceA>();
122122
Assert.That(parentSingleton, Is.InstanceOf<NoDependencyServiceA>());
123+
Assert.That(parentSingleton, Is.EqualTo(parentContainer.Resolve<NoDependencyServiceA>()));
123124

124125
var childSingleton = grandChildContainer.Resolve<ServiceA>();
125126
Assert.That(childSingleton, Is.InstanceOf<ServiceA>());
126127
Assert.That(childSingleton.Service2, Is.InstanceOf<I2>());
128+
Assert.That(childSingleton, Is.EqualTo(childContainer.Resolve<ServiceA>()));
127129

128130
var grandChildSingleton = grandChildContainer.Resolve<ServiceB>();
129131
Assert.That(grandChildSingleton, Is.InstanceOf<ServiceB>());

0 commit comments

Comments
 (0)