Outputting trace and debug information
When a template doesn't behave as you expect, you can gather information with the .NET System.Diagnostics.Trace and System.Diagnostics.Debug classes. They write to the Debug pane of the Output window.
The two classes have the same members. The difference is that Trace is always active, while Debug is active only when the template is compiled in debug mode.
System.Diagnostics.Trace.WriteLine("Template code reached this point.");
Useful members
| Member | Type | Description |
|---|---|---|
Assert |
Method | Checks a condition and displays a message if the condition is false. |
Fail |
Method | Displays an error message. |
Indent |
Method | Increases the current IndentLevel by one. |
IndentLevel |
Property | The indent level. |
IndentSize |
Property | The number of spaces in an indent. |
Unindent |
Method | Decreases the current IndentLevel by one. |
Write |
Method | Writes the given information. |
WriteIf |
Method | Writes the given information only if a condition is true. |
WriteLine |
Method | Same as Write, followed by a line break. |
WriteLineIf |
Method | Same as WriteIf, followed by a line break. |