Access to template generated source code

Mar 1, 2011 at 7:08 PM

Is there any easy way to get access to the generated source code for templates? I'm new to Razor and find that I'm struggling with a lot of syntax errors in my templates. I'd love to be able to see the code that's generated to make it easier to figure out what's gone wrong.

For example, here's a typical error message:

{c:\Users\scottb\AppData\Local\Temp\tedws2oh.0.cs(39,1) : error CS1501: No overload for method 'Write' takes 0 arguments}

There's a temporary source file mentioned there, but by the time I get the error message it's not on the drive any longer. The Line,Column number stuff isn't helpful since it's for the generated .cs file and not for the template file.



Mar 2, 2011 at 7:58 AM

We could add the generated source code to the exception data, but can only do this in full trust scenarios (because we have to invoke a CodeDomProvider to generate the code. In medium trust environments, we don't access the CodeDomProvider directly, but through the ASP.NET build system, so don't have access to the generated source.

Mar 3, 2011 at 8:43 PM

If it's easy to do, adding the source code to the exception data would be terrifically handy. In my case it's a WPF application so full trust is no problem.