roslyn-sdk icon indicating copy to clipboard operation
roslyn-sdk copied to clipboard

Add Source Generator to Compilation from NuGet Package

Open HavenDV opened this issue 2 years ago • 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?

HavenDV avatar May 17 '23 04:05 HavenDV

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

HavenDV avatar May 17 '23 04:05 HavenDV

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 https://github.com/dotnet/roslyn-sdk/issues/1087 as well.

Youssef1313 avatar Jun 04 '23 07:06 Youssef1313