Hello! Thanks for the great work on VContainer!
I've encountered an issue using the VContainer.SourceGenerator.dll source generator together with multiple assemblies.
I can see that the injectors are being generated properly. However, in our project we use multiple assemblies with one top level assembly responsible for defining the LifetimeScope and registering all the dependencies. Since it's this assembly that contain all the builder.Register<T> statements, the Injectors get put into this assembly. When VContainer then tries to find the generated injector it can't find it and falls back to using the reflection injector since it only looks in the assembly where T is defined:
|
var generatedType = key.Assembly.GetType($"{key.FullName}GeneratedInjector", false); |
This basically means that if you register dependencies in one assembly from another assembly it will never use the generated injectors. For us this means we can't really use the source generators since we need to be able to register and define dependencies in different assemblies.
Hello! Thanks for the great work on VContainer!
I've encountered an issue using the
VContainer.SourceGenerator.dllsource generator together with multiple assemblies.I can see that the injectors are being generated properly. However, in our project we use multiple assemblies with one top level assembly responsible for defining the
LifetimeScopeand registering all the dependencies. Since it's this assembly that contain all thebuilder.Register<T>statements, theInjectorsget put into this assembly. WhenVContainerthen tries to find the generated injector it can't find it and falls back to using the reflection injector since it only looks in the assembly where T is defined:VContainer/VContainer/Assets/VContainer/Runtime/Internal/InjectorCache.cs
Line 16 in 0093a45
This basically means that if you register dependencies in one assembly from another assembly it will never use the generated injectors. For us this means we can't really use the source generators since we need to be able to register and define dependencies in different assemblies.