Replies: 3 comments 1 reply
-
I'm in the same boat here. I have managed to get a debugger to attach, and stop on a breakpoint... but it's not actually been helpful for me. I would greatly like to stop debugging in one of the razor templates, but that doesn't work. I am able to enter the debugger in vscode. The code I have that allows me to stop the debugger is: using Statiq.App;
using Statiq.Web;
Console.WriteLine("Breakpoint here");
await Bootstrapper // Also Breakpoint here...
.Factory
.CreateWeb(args)
.RunAsync();
Console.WriteLine("Final Breakpoint here..."); When I run:
It then waits as it says for me to attach the debugger. Once the debugger it continues until the Final Breakpoint here... line and then enters the debugger. The other way I've been able to debug it, and actually hit breakpoints before the bootstrapper is to use the |
Beta Was this translation helpful? Give feedback.
-
Note that since Statiq generators are just normal .NET projects, running in debug mode straight from Visual Studio, Rider, etc. is always possible. That's actually how I debug my generators most of the time these days. So there are a few options:
Note that Statiq also bundles debugging symbols with SourceLink support, so stepping into Statiq source code should be possible (providing you're IDE supports SourceLink and/or decompilation and you've configured it to do so - I.e. turned off "just my code"). As for debugging Razor assemblies, I know a couple folks have had limited luck doing so but that's not "official" supported right now in the sense that I haven't looked into it very much and haven't spent time ensuring it works. Definitely something I'd like to do, just hasn't risen to top priority yet. That said, I do know the Razor engine is outputting assemblies and PDB files right now, so in theory all the parts are there to make this work. |
Beta Was this translation helpful? Give feedback.
-
I find that Razor debugging works in Visual Studio (2022 and 2019) but not in Rider. You have to disable "Just My Code" in the debugger settings. |
Beta Was this translation helpful? Give feedback.
-
When experimenting with things I'm not sure how they really work, I find myself wishing for a way to debug the execution, to see what the inputs and outputs to everything is. I am guessing that this might not be possible from inside a razor template, but maybe there is some way to write some testing code in the C# application code that I can step into with a debugger that could give me more insight?
I am using VSCode and compiling from the powershell terminal, but I'd happily use anything else that could help with this.
Beta Was this translation helpful? Give feedback.
All reactions