summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mscorlib/src/System/Diagnostics/Debug.Unix.cs21
-rw-r--r--src/mscorlib/src/System/Diagnostics/Debug.Windows.cs9
-rw-r--r--src/mscorlib/src/System/Diagnostics/Debug.cs8
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)
{
}
}