Open ignatandrei opened 2 years ago
I highly recommend debugging source generators by writing unit tests and debugging them from Test Explorer. Debugging a source generator inside of a live Visual Studio instance will be problematic due to their incremental nature and difficulty predicting when they will start.
I don't have a direct answer to debugging inside Visual Studio because for all the source generators I've worked on, I've never tried to debug inside a live instance because the result is always that much worse. The only thing I will do often is open the generated code from underneath the Analyzers node in Solution Explorer to visually inspect it.
I agree with @sharwell - take a look at https://dominikjeske.github.io/source-generators/ in Testing section
For debug Roslyn Source Code Generators in VS2022 , we have had first
Debugger.Launch
and later
But I cannot figure how to do it in VS2022. What will be the profile ?