Skip to content
Merged
14 changes: 11 additions & 3 deletions xml/System.Diagnostics/Debugger.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,17 @@ Console.WriteLine("Hello, world.");
<Parameter Name="exception" Type="System.Exception" Index="0" FrameworkAlternate="net-9.0" />
</Parameters>
<Docs>
<param name="exception">To be added.</param>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
<param name="exception">The user-unhandled exception.</param>
<summary>
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.
</summary>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
This API is designed to be used with <xref:System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute>. 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 `exception` parameter.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="DefaultCategory">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,39 @@
</Attribute>
</Attributes>
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
<summary>
If a .NET Debugger is attached that supports the <see cref="M:System.Diagnostics.Debugger.BreakForUserUnhandledException(System.Exception)" /> API, the debugger won't break on user-unhandled exceptions when the exception is caught by a method with this attribute, unless <see cref="M:System.Diagnostics.Debugger.BreakForUserUnhandledException(System.Exception)" /> is called.
</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Visual Studio has added support for catching asynchronous user-unhandled exceptions and it's enabled by default. This feature has existed for a long time for synchronous methods, but not for async / await methods. The <see cref="M:System.Diagnostics.Debugger.BreakForUserUnhandledException(System.Exception)" /> method 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(System.Exception)>.
## Example
```csharp
[MethodImpl(MethodImplOptions.NoInlining)]
[DebuggerDisableUserUnhandledExceptions]
static async Task InvokeUserCode(Func<Task> userCode)
{
try
{
await userCode();
}
catch (Exception ex)
{
if (TryHandleWithFilter(ex))
{
return; // example case where we don't want to break for user-unhandled exceptions
}
Debugger.BreakForUserUnhandledException(e); // debugger will stop here and show the exception if attached.
}
}
```
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
Expand Down