Skip to content

Commit 648c9aa

Browse files
committed
Add DebuggerDisableUserUnhandledExceptionsAttribute docs
1 parent a43c0ec commit 648c9aa

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

xml/System.Diagnostics/Debugger.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@ Console.WriteLine("Hello, world.");
222222
<summary>
223223
<para>Signals a breakpoint to an attached debugger with the <paramref name="exception" /> details if a .NET debugger is attached with break on user-unhandled exception enabled and a method attributed with DebuggerDisableUserUnhandledExceptionsAttribute calls this method.</para>
224224
</summary>
225-
<remarks>To be added.</remarks>
225+
<remarks>
226+
<format type="text/markdown"><![CDATA[
227+
228+
## Remarks
229+
This API is designed to be used with <xref:System.Diagnostics.DebuggerDisableUserUnhandledExceptions>. If a .NET debugger is attached and the debugger supports breaking on user-unhandled exceptions, this method signals a breakpoint to the debugger with the <paramref name="exception" />
230+
]]></format>
231+
</remarks>
226232
</Docs>
227233
</Member>
228234
<Member MemberName="DefaultCategory">

xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,36 @@
2323
<summary>
2424
<para>If a .NET Debugger is attached which supports the Debugger.BreakForUserUnhandledException(Exception) API, this attribute will prevent the debugger from breaking on user-unhandled exceptions when the exception is caught by a method with this attribute, unless BreakForUserUnhandledException is called.</para>
2525
</summary>
26-
<remarks>To be added.</remarks>
26+
<remarks>
27+
<format type="text/markdown"><![CDATA[
28+
29+
## Remarks
30+
Visual Studio has added support for catching asynchronous user-unhandled exceptions and is enabled by default. This feature has existed for a long time for synchronous methods, but not for async / await methods. The BreakForUserUnhandledException disables the feature for specific methods. This is useful for exceptions that propagate through user code but are expected to be handled by framework code. This attribute is designed to be used along with <xref:System.Diagnostics.Debugger.BreakForUserUnhandledException>.
31+
32+
## Example
33+
34+
```csharp
35+
[MethodImpl(MethodImplOptions.NoInlining)]
36+
[DebuggerDisableUserUnhandledExceptions]
37+
static async Task InvokeUserCode(Func<Task> userCode)
38+
{
39+
try
40+
{
41+
await userCode();
42+
}
43+
catch (Exception ex)
44+
{
45+
if (TryHandleWithFilter(ex))
46+
{
47+
return; // example case where we don't want to break for user-unhandled exceptions
48+
}
49+
50+
Debugger.BreakForException(e); // debugger will stop here and show the exception if attached.
51+
}
52+
}
53+
```
54+
]]></format>
55+
</remarks>
2756
</Docs>
2857
<Members>
2958
<Member MemberName=".ctor">

0 commit comments

Comments
 (0)