Skip to content

Injectors generated by Source Generators not used when using multiple assemblies #822

Description

@timlindeberg

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions