Closed hendrik-schulte closed 4 months ago
When using LifetimeScope.Create, there is no need to call Build manually.
This line seems to be causing problems.
scope.Build();
It seems to actually call .Build() on the LifetimeScope
base class.
( This is admittedly a bit odd. Maybe it should be an error, but it could be a breaking change..
Incidentally, you can write tests without using LifetimeScope (MonoBehaviour) by doing the following. For reference.
var builder = new ContainerBuilder();
builder.Register<Foo>(Lifetime.Scoped);
// ...
var container = builder.Build();
I was playing around with a
LifetimeScope
in editmode and playmode tests and ran into an issue that seems like a bug to me. This is my setup:This is the test:
The test passes and all callbacks work fine with the following output:
Just as expected.
However, when I run the very same test as a playmode test, I get the following exception:
VContainer.VContainerException : No such registration of type: IFoo
Also, if I don't resolve
IFoo
and ommit the assertions, the dispose callbacks are not called:Unity 2022.3.24f1 VContainer 1.15.4 Unity Test Framework 2.0.1-pre.18