diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs index 7f0fa52f988253..a0106b1816ec5d 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs @@ -5,7 +5,7 @@ namespace System.Diagnostics { - public static class Debugger + public static partial class Debugger { [MethodImpl(MethodImplOptions.NoInlining)] [DebuggerHidden] // this helps VS appear to stop on the source line calling Debugger.Break() instead of inside it diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 9045c03a920b96..533ff2cb96b213 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -290,7 +290,9 @@ + + @@ -2799,4 +2801,4 @@ - + \ No newline at end of file diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs new file mode 100644 index 00000000000000..77e97ba62f4653 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; + +namespace System.Diagnostics +{ + public static partial class Debugger + { + /// + /// 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. + /// + /// The user-unhandled exception. + [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] + public static void BreakForUserUnhandledException(Exception exception) + { + } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.cs new file mode 100644 index 00000000000000..9da4dae623afc5 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebuggerDisableUserUnhandledExceptionsAttribute.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Diagnostics +{ + /// + /// 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. + /// + [AttributeUsage(AttributeTargets.Method)] + public sealed class DebuggerDisableUserUnhandledExceptionsAttribute : Attribute + { + } +} diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index e7e61105315e09..db837e955d134d 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -8666,6 +8666,7 @@ public static partial class Debugger public static readonly string? DefaultCategory; public static bool IsAttached { get { throw null; } } public static void Break() { } + public static void BreakForUserUnhandledException(System.Exception exception) { } public static bool IsLogging() { throw null; } public static bool Launch() { throw null; } public static void Log(int level, string? category, string? message) { } @@ -8683,6 +8684,11 @@ public enum DebuggerBrowsableState Collapsed = 2, RootHidden = 3, } + [System.AttributeUsage(System.AttributeTargets.Method)] + public sealed class DebuggerDisableUserUnhandledExceptionsAttribute : System.Attribute + { + public DebuggerDisableUserUnhandledExceptionsAttribute() { } + } [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple=true)] public sealed partial class DebuggerDisplayAttribute : System.Attribute { diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs index 6d3593b6e05e43..ccd8fb6d75ed18 100644 --- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs +++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs @@ -5,7 +5,7 @@ namespace System.Diagnostics { - public static class Debugger + public static partial class Debugger { public static readonly string? DefaultCategory;