adoconnection / RazorEngineCore

.NET6 Razor Template Engine
MIT License
565 stars 84 forks source link

options to generate debugging information? #125

Closed davethieben closed 8 months ago

davethieben commented 1 year ago

Hey all, thanks so much for the lib. It's a welcome upgrade over the old RazorEngine.

We've got some large Razor templates and we modify them we sometimes get errors like this:

Message: 
System.NullReferenceException : Object reference not set to an instance of an object.

  Stack Trace: 
Template.ExecuteAsync()
RazorEngineCompiledTemplate`1.RunAsync(Action`1 initializer)
RazorEngineCompiledTemplate`1.Run(Action`1 initializer)

Not very helpful, and very difficult to figure out where the problem is. Is there any way to add compile options to add debug symbols or line numbers so they show up in the stack trace? that would be immensely helpful.

TIA.

adoconnection commented 1 year ago

Hi, thanks! There are two fields: Errors and GeneratedCode to help you out

https://github.com/adoconnection/RazorEngineCore/blob/c6ff4880e6a31332d16006e2fdc043f10ebbfa78/RazorEngineCore/RazorEngine.cs#L112-L116

adoconnection commented 1 year ago

Ah, sorry its when you run templates. There was a uservoice thread once where community asked better NullReferenceException text to see what exactly was null, with thousands of voices, but apparently this is something microsoft is not capable of 😅

One way to generate debugging info: https://github.com/adoconnection/RazorEngineCore/pull/111 not yet merged ⌛

A9G-Data-Droid commented 9 months ago

Eak, I just hit this error and I need that debug information. It makes me sad to see the PR #111 has been stale for over a year.

adoconnection commented 8 months ago

done, released in 2023.11.1 https://www.nuget.org/packages/RazorEngineCore/