dotnet/roslyn-sdk

Add Source Generator to Compilation from NuGet Package

HavenDV opened this issue · 2 comments

For now, I'm using the Microsoft.CodeAnalysis.Testing and ReferenceAssemblies class to resolve packages and add them to Compilation. But this does not work for packages that contain source code generators. Is there a way to add source code generators from a NuGet package using Roslyn or Testing packages?

I guess I need to re-extract the NuGet archives myself, check the analyzers folder for dlls, open them, extract all generator classes, and use CSharpGeneratorDriver to update Compilation.
I just want to make sure it's not already implemented

Should the generator added from NuGet package contribute to the expected generated sources? If yes, it will be quite breaking. Maybe a flag should be added along with this? In this case, this will be a sufficient solution for #1087 as well.