Can you allow the in-memory class generated by the RazorPageHost to be compiled with debug information included (and without “/optimize” if necessary).
RazorFormat.IncludeDebugInformation and RazorFormat.CompileFilter are new options added in this commit that will let you modify the Razor CompilerParameters.
By default it will include DebugInfo in DebugMode.
The only tweak I would make is to remove the “/optimize” by default from the CompilerOptions if IncludeDebugInformation is true.
Without this, you can step through the razor code in the debugger, but you won’t have access to the local variables (the debugger says “Cannot evaluate expression because the code of the current method is optimized”).
I know it can already be done using the new CompileFilter on RazorFormat, but I think it’s a more sensible default, so razor can be easily debugged if DebugMode is on, without needing to override the compiler options.