Skip to content

Commit bf550ee

Browse files
shehrozeeeTheAtomicOption
authored andcommitted
Update Readme with usgae info for debugging
1 parent b30db9a commit bf550ee

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,23 @@ IRazorEngineCompiledTemplate compiledTemplate = razorEngine.Compile(templateText
208208
string result = compiledTemplate.Run(new { name = "Hello" });
209209
```
210210

211+
#### Debugging templates
212+
Add the following line in your template source and your debugger(vs code/vs studio) break on it.
213+
```cs
214+
System.Diagnostics.Debugger.Break();
215+
```
216+
Use this overload for the Compile function and pass true for the addPdb argument
217+
```cs
218+
razorEngine.Compile(templateSource, builder =>
219+
{
220+
builder.AddAssemblyReferenceByName("System.Security"); // by name
221+
builder.AddAssemblyReference(typeof(System.IO.File)); // by type
222+
builder.AddAssemblyReference(Assembly.Load("source")); // by reference
223+
},
224+
true); //This 'true' will enable debugging.
225+
```
226+
Your debbuger will ask you to provide the path to the source file, by defult it is set to be generated in %temp% (point your there when asked for the file).
227+
211228

212229
#### Credits
213230
This package is inspired by [Simon Mourier SO post](https://stackoverflow.com/a/47756437/267736)
@@ -216,6 +233,8 @@ This package is inspired by [Simon Mourier SO post](https://stackoverflow.com/a/
216233
#### Changelog
217234
* 2022.8.1
218235
* Proper namespace handling for nested types and types without namespace #113 (thanks [@Kirmiir](https://github.com/Kirmiir))
236+
* 2022.7.6
237+
* Added the option to genereate pdb alongside the assembly which allows debugging the templates.
219238
* 2022.1.2
220239
* #94 publish as single file fix
221240
* 2022.1.1

0 commit comments

Comments
 (0)