How can I debug the ISourceGenerator
code during the build process with vscode? Examples on the net use Debugger.Launch()
but this only works in Visual Studio.
[Generator]
public class HelloWorldGenerator : ISourceGenerator
{
public void Execute(GeneratorExecutionContext context)
{
}
public void Initialize(GeneratorInitializationContext context)
{
if (!Debugger.IsAttached)
{
// how to make it break here?
Debugger.Launch();
}
}
}
If you add such construction:
while (!System.Diagnostics.Debugger.IsAttached)
System.Threading.Thread.Sleep(500);
you will be able to stop build process until you attach any debugger you want. I use Rider IDE, but this should work for VS Code too. When it stucks in cycle, it is available for attaching as .NET Core process:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.