How do I get SysInternals DebugView to display indents?
I'm using SysInternals DebugView with my .Net application. I've tried using the Indent feature of the .Net Debug class, but DebugView just seems to represent this as a NewLine character.
Does anyone know if it's possible to get DebugView to display the indents?
Sample Code:
static void Main (string[] args)
{
Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.Indent();
Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.Indent();
Debug.WriteLine("Indent level: {0}", Debug.Inde开发者_JS百科ntLevel);
Debug.Indent();
Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.Unindent();
Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.Unindent();
Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.Unindent();
Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
}
Output:
[9632] Indent level: 0
[9632]
[9632] Indent level: 1
[9632]
[9632]
[9632] Indent level: 2
[9632]
[9632]
[9632]
[9632] Indent level: 3
[9632]
[9632]
[9632] Indent level: 2
[9632]
[9632] Indent level: 1
[9632] Indent level: 0
What I'd Like to see:
[9632] Indent level: 0
[9632] Indent level: 1
[9632] Indent level: 2
[9632] Indent level: 3
[9632] Indent level: 2
[9632] Indent level: 1
[9632] Indent level: 0
Rik
But wait! It looks like it is possible. You just need to turn off the Force Carriage Returns feature on the Options menu.
I discovered the answer here: http://forum.sysinternals.com/topic26797_post131196.html#131196
Here's the text:
By default, the Force Carriage Returns option is enabled, which displays every string passed to a debug output function on a separate line, whether or not that text is terminated with a carriage return. If you disable that option in the Options menu, DebugView buffers output text in memory and adds it to the display only when a carriage return is encountered or the memory buffer is filled (approximately 4192 characters). This allows applications and drivers to build output lines with multiple invocations of debug output functions.
I don't think you can make DebugView do this way. It captures individual output writes, so it seems that when you do Debug.WriteLine
Debug class outputs indentation space individually as separate OutputDebugString
calls. What you definitely still can do is adding indentation space yourself and have your writes mapped into single underlying API calls:
string currentIndent = " ";
// ...
Debug.WriteLine(currentIndent + "Indent level: {0}", Debug.IndentLevel);
精彩评论