Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f002587

Browse files
Added Trace and Debug Snippets (Immediate Window)
1 parent c137717 commit f002587

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎CSharp Code Samples/CodeSamples/Attributes/DebuggingSample.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,28 @@ public void DebuggerStepThroughMethod()
113113
{
114114
Console.WriteLine($"Debugger stepped through this method.");
115115
}
116+
117+
/// <summary>
118+
/// Trace and debug messages
119+
/// This shows in Immediate Window (Ctrl + Alt + I)
120+
/// e.g. Input in Immediate window (after build): ?(new DebuggingSample().Execute())
121+
/// </summary>
122+
public void ImmediateWindowMessages()
123+
{
124+
Trace.WriteLine("Some Trace messages to follow:");
125+
Trace.IndentSize = 2;
126+
Trace.Indent();
127+
Trace.TraceInformation("This is Trace information.");
128+
Trace.Indent();
129+
Trace.TraceInformation("This is Trace information - indented.");
130+
Trace.Unindent();
131+
Trace.TraceWarning("This is Trace Warning.");
132+
Trace.TraceError("This is Trace Error.");
133+
Trace.Unindent();
134+
Trace.Flush();
135+
//
136+
Debug.WriteLine("This is Debug Line.");
137+
}
116138
}
117139

118140
public class DebuggingSample : SampleExecute
@@ -121,12 +143,17 @@ public override void Execute()
121143
{
122144
Title("DebuggingSampleExecute");
123145
Section("Creating class (if breakpoint is used here, debugger output will be formatted as in DebuggerDisplay())");
146+
124147
DebuggerExamplesDebuggerDisplay debuggerExample = new DebuggerExamplesDebuggerDisplay();
125148
//set breakpoint on next line and hover over "debuggerExample" variable
126149
debuggerExample.DebuggerStepThroughMethod();
127150
debuggerExample.ExecuteOnlyInDebugMode();
128151
debuggerExample.ExecuteOnlyInReleaseMode();
129152
debuggerExample.RuntimeDebuggerAttached();
153+
154+
Section("Immediate Window Messages");
155+
debuggerExample.ImmediateWindowMessages();
156+
130157
Finish();
131158
}
132159
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /