diff options
author | Dan Moseley <danmose@microsoft.com> | 2017-04-03 17:15:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-03 17:15:24 -0700 |
commit | d8250b52fc596cc9c13d6abbc5aa85dd1440b0d9 (patch) | |
tree | f3722c16d096da53535c8023acac43e29e5143a4 /src | |
parent | 4451f848e195ca554b96afddbee48b9ac5f3279e (diff) | |
download | coreclr-d8250b52fc596cc9c13d6abbc5aa85dd1440b0d9.tar.gz coreclr-d8250b52fc596cc9c13d6abbc5aa85dd1440b0d9.tar.bz2 coreclr-d8250b52fc596cc9c13d6abbc5aa85dd1440b0d9.zip |
Debug.Assert FF (#10652)
Diffstat (limited to 'src')
-rw-r--r-- | src/mscorlib/src/System/Diagnostics/Debug.Unix.cs | 21 | ||||
-rw-r--r-- | src/mscorlib/src/System/Diagnostics/Debug.Windows.cs | 9 | ||||
-rw-r--r-- | src/mscorlib/src/System/Diagnostics/Debug.cs | 8 |
3 files changed, 15 insertions, 23 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/Debug.Unix.cs b/src/mscorlib/src/System/Diagnostics/Debug.Unix.cs index 2ec76a5d18..495f2f713c 100644 --- a/src/mscorlib/src/System/Diagnostics/Debug.Unix.cs +++ b/src/mscorlib/src/System/Diagnostics/Debug.Unix.cs @@ -8,11 +8,7 @@ namespace System.Diagnostics { public static partial class Debug { - private static string NewLine => "\n"; - - private const string EnvVar_DebugWriteToStdErr = "COMPlus_DebugWriteToStdErr"; - private static readonly bool s_shouldWriteToStdErr = - Internal.Runtime.Augments.EnvironmentAugments.GetEnvironmentVariable(EnvVar_DebugWriteToStdErr) == "1"; + private static readonly bool s_shouldWriteToStdErr = Environment.GetEnvironmentVariable("COMPlus_DebugWriteToStdErr") == "1"; private static void ShowAssertDialog(string stackTrace, string message, string detailMessage) { @@ -22,16 +18,11 @@ namespace System.Diagnostics } else { - // TODO: #3708 Determine if/how to put up a dialog instead. - var exc = new DebugAssertException(message, detailMessage, stackTrace); - if (!s_shouldWriteToStdErr) - { - // We always want to print out Debug.Assert failures to stderr, even if - // !s_shouldWriteToStdErr, so if it wouldn't have been printed in - // WriteCore (only when s_shouldWriteToStdErr), print it here. - WriteToStderr(exc.Message); - } - throw exc; + // In Core, we do not show a dialog. + // Fail in order to avoid anyone catching an exception and masking + // an assert failure. + var ex = new DebugAssertException(message, detailMessage, stackTrace); + Environment.FailFast(ex.Message, ex); } } diff --git a/src/mscorlib/src/System/Diagnostics/Debug.Windows.cs b/src/mscorlib/src/System/Diagnostics/Debug.Windows.cs index f9b097c230..095e9b6985 100644 --- a/src/mscorlib/src/System/Diagnostics/Debug.Windows.cs +++ b/src/mscorlib/src/System/Diagnostics/Debug.Windows.cs @@ -6,8 +6,6 @@ namespace System.Diagnostics { public static partial class Debug { - private static string NewLine => "\r\n"; - private static void ShowAssertDialog(string stackTrace, string message, string detailMessage) { if (Debugger.IsAttached) @@ -16,8 +14,11 @@ namespace System.Diagnostics } else { - // TODO: #3708 Determine if/how to put up a dialog instead. - throw new DebugAssertException(message, detailMessage, stackTrace); + // In Core, we do not show a dialog. + // Fail in order to avoid anyone catching an exception and masking + // an assert failure. + var ex = new DebugAssertException(message, detailMessage, stackTrace); + Environment.FailFast(ex.Message, ex); } } diff --git a/src/mscorlib/src/System/Diagnostics/Debug.cs b/src/mscorlib/src/System/Diagnostics/Debug.cs index 2dfde8d903..59f3c378da 100644 --- a/src/mscorlib/src/System/Diagnostics/Debug.cs +++ b/src/mscorlib/src/System/Diagnostics/Debug.cs @@ -122,7 +122,7 @@ namespace System.Diagnostics private static string FormatAssert(string stackTrace, string message, string detailMessage) { - string newLine = GetIndentString() + NewLine; + string newLine = GetIndentString() + Environment.NewLine; return SR.DebugAssertBanner + newLine + SR.DebugAssertShortMessage + newLine + message + newLine @@ -140,7 +140,7 @@ namespace System.Diagnostics [System.Diagnostics.Conditional("DEBUG")] public static void WriteLine(string message) { - Write(message + NewLine); + Write(message + Environment.NewLine); } [System.Diagnostics.Conditional("DEBUG")] @@ -159,7 +159,7 @@ namespace System.Diagnostics s_needIndent = false; } s_WriteCore(message); - if (message.EndsWith(NewLine)) + if (message.EndsWith(Environment.NewLine)) { s_needIndent = true; } @@ -311,7 +311,7 @@ namespace System.Diagnostics private sealed class DebugAssertException : Exception { internal DebugAssertException(string message, string detailMessage, string stackTrace) : - base(message + NewLine + detailMessage + NewLine + stackTrace) + base(message + Environment.NewLine + detailMessage + Environment.NewLine + stackTrace) { } } |