From a43c0ec7d17f98c451a35919cfb97fb83a1d4245 Mon Sep 17 00:00:00 2001 From: "Tom McDonald (from Dev Box)" Date: Wed, 18 Sep 2024 00:39:48 -0400 Subject: [PATCH 01/10] Document BreakForUserUnhandledException and DebuggerDisableUserUnhandledExceptionsAttribute --- xml/System.Diagnostics/Debugger.xml | 6 ++++-- .../DebuggerDisableUserUnhandledExceptionsAttribute.xml | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xml/System.Diagnostics/Debugger.xml b/xml/System.Diagnostics/Debugger.xml index e4310db60a1..0b35b2c5137 100644 --- a/xml/System.Diagnostics/Debugger.xml +++ b/xml/System.Diagnostics/Debugger.xml @@ -218,8 +218,10 @@ Console.WriteLine("Hello, world."); - To be added. - To be added. + The user-unhandled exception. + + Signals a breakpoint to an attached debugger with the details if a .NET debugger is attached with break on user-unhandled exception enabled and a method attributed with DebuggerDisableUserUnhandledExceptionsAttribute calls this method. + To be added. diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index 52574402d17..af7ddf0ce56 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -20,7 +20,9 @@ - To be added. + + 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. + To be added. From 648c9aab0afcdec165e2eceb12b6271bddd43f22 Mon Sep 17 00:00:00 2001 From: "Tom McDonald (from Dev Box)" Date: Wed, 18 Sep 2024 01:23:32 -0400 Subject: [PATCH 02/10] Add DebuggerDisableUserUnhandledExceptionsAttribute docs --- xml/System.Diagnostics/Debugger.xml | 8 ++++- ...isableUserUnhandledExceptionsAttribute.xml | 31 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/xml/System.Diagnostics/Debugger.xml b/xml/System.Diagnostics/Debugger.xml index 0b35b2c5137..a960f3a9b34 100644 --- a/xml/System.Diagnostics/Debugger.xml +++ b/xml/System.Diagnostics/Debugger.xml @@ -222,7 +222,13 @@ Console.WriteLine("Hello, world."); Signals a breakpoint to an attached debugger with the details if a .NET debugger is attached with break on user-unhandled exception enabled and a method attributed with DebuggerDisableUserUnhandledExceptionsAttribute calls this method. - To be added. + + . 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 + ]]> + diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index af7ddf0ce56..8664b664f43 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -23,7 +23,36 @@ 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. - To be added. + + . + + ## Example + + ```csharp + [MethodImpl(MethodImplOptions.NoInlining)] + [DebuggerDisableUserUnhandledExceptions] + static async Task InvokeUserCode(Func 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.BreakForException(e); // debugger will stop here and show the exception if attached. + } + } + ``` + ]]> + From 64b265e3638f1903dab3be28b45a9c472cace3bf Mon Sep 17 00:00:00 2001 From: "Tom McDonald (from Dev Box)" Date: Wed, 18 Sep 2024 13:11:50 -0400 Subject: [PATCH 03/10] Fix warnings --- xml/System.Diagnostics/Debugger.xml | 2 +- .../DebuggerDisableUserUnhandledExceptionsAttribute.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xml/System.Diagnostics/Debugger.xml b/xml/System.Diagnostics/Debugger.xml index a960f3a9b34..a8374c558f1 100644 --- a/xml/System.Diagnostics/Debugger.xml +++ b/xml/System.Diagnostics/Debugger.xml @@ -226,7 +226,7 @@ Console.WriteLine("Hello, world."); . 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 + This API is designed to be used with . 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. /> ]]> diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index 8664b664f43..d47e5605d52 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -27,7 +27,7 @@ . + 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 . ## Example From 4fe7e0c78139cbb6aa6b2d9b433f957dbfd8ead6 Mon Sep 17 00:00:00 2001 From: "Tom McDonald (from Dev Box)" Date: Thu, 19 Sep 2024 01:32:35 -0400 Subject: [PATCH 04/10] Remove superfluous xml termination character --- xml/System.Diagnostics/Debugger.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Diagnostics/Debugger.xml b/xml/System.Diagnostics/Debugger.xml index a8374c558f1..1289e16ac12 100644 --- a/xml/System.Diagnostics/Debugger.xml +++ b/xml/System.Diagnostics/Debugger.xml @@ -226,7 +226,7 @@ Console.WriteLine("Hello, world."); . 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. /> + This API is designed to be used with . 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. ]]> From 97436edf6fe812b5a3c59490f29d3acdb3b30bbd Mon Sep 17 00:00:00 2001 From: Tom McDonald Date: Thu, 19 Sep 2024 01:34:30 -0400 Subject: [PATCH 05/10] Update xml/System.Diagnostics/Debugger.xml Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- xml/System.Diagnostics/Debugger.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Diagnostics/Debugger.xml b/xml/System.Diagnostics/Debugger.xml index 1289e16ac12..bb3496c5b8b 100644 --- a/xml/System.Diagnostics/Debugger.xml +++ b/xml/System.Diagnostics/Debugger.xml @@ -220,7 +220,7 @@ Console.WriteLine("Hello, world."); The user-unhandled exception. - Signals a breakpoint to an attached debugger with the details if a .NET debugger is attached with break on user-unhandled exception enabled and a method attributed with DebuggerDisableUserUnhandledExceptionsAttribute calls this method. + Signals a breakpoint to an attached debugger with the details if a .NET debugger is attached with break on user-unhandled exception enabled and a method attributed with DebuggerDisableUserUnhandledExceptionsAttribute calls this method. Date: Thu, 19 Sep 2024 01:34:41 -0400 Subject: [PATCH 06/10] Update xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .../DebuggerDisableUserUnhandledExceptionsAttribute.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index d47e5605d52..e8abbd6b4a8 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -21,7 +21,7 @@ - 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. + If a .NET Debugger is attached that supports the API, the debugger won't break on user-unhandled exceptions when the exception is caught by a method with this attribute, unless is called. Date: Thu, 19 Sep 2024 01:34:51 -0400 Subject: [PATCH 07/10] Update xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .../DebuggerDisableUserUnhandledExceptionsAttribute.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index e8abbd6b4a8..0018a64687e 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -27,7 +27,7 @@ . + 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 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 . ## Example From 4b27a9a6e447716f4f259884475cf220d511164c Mon Sep 17 00:00:00 2001 From: "Tom McDonald (from Dev Box)" Date: Thu, 19 Sep 2024 01:36:18 -0400 Subject: [PATCH 08/10] PR Feedback --- .../DebuggerDisableUserUnhandledExceptionsAttribute.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index 0018a64687e..4535e2f4fc8 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -47,7 +47,7 @@ return; // example case where we don't want to break for user-unhandled exceptions } - Debugger.BreakForException(e); // debugger will stop here and show the exception if attached. + Debugger.BreakForUserUnhandledException(e); // debugger will stop here and show the exception if attached. } } ``` From 66866d28bf61fcfac32ed1cfadb5072c0ab7a672 Mon Sep 17 00:00:00 2001 From: "Tom McDonald (from Dev Box)" Date: Thu, 19 Sep 2024 11:32:34 -0400 Subject: [PATCH 09/10] Remove extra XML termination para tag --- .../DebuggerDisableUserUnhandledExceptionsAttribute.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index 4535e2f4fc8..26dfc1d43d3 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -21,7 +21,7 @@ - If a .NET Debugger is attached that supports the API, the debugger won't break on user-unhandled exceptions when the exception is caught by a method with this attribute, unless is called. + If a .NET Debugger is attached that supports the API, the debugger won't break on user-unhandled exceptions when the exception is caught by a method with this attribute, unless is called. Date: Mon, 23 Sep 2024 08:17:21 -0700 Subject: [PATCH 10/10] Update xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml --- .../DebuggerDisableUserUnhandledExceptionsAttribute.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml index 26dfc1d43d3..5f321f84b1d 100644 --- a/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.xml @@ -27,7 +27,7 @@ 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 . + 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 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 . ## Example