dotnet / roslyn-sdk

Roslyn-SDK templates and Syntax Visualizer
MIT License
512 stars 257 forks source link

Source generator sample has errors in Visual Studio #1150

Closed parched closed 6 months ago

parched commented 6 months ago

If I open https://github.com/dotnet/roslyn-sdk/blob/main/samples/CSharp/SourceGenerators/SourceGenerators.sln from a fresh clone in VS I get a lot of errors when I open the demo files.

image

When I build the solution the errors go away.

Is this the intended behavior or is it a bug in VS or in these samples?

sharwell commented 6 months ago

The source generator project needs to be built once and then restart Visual Studio for it to take effect. This is a known limitation of source generators that are defined in the same solution where they are used.