diff options
Diffstat (limited to 'src/mscorlib/src/System/Diagnostics/Debug.Windows.cs')
-rw-r--r-- | src/mscorlib/src/System/Diagnostics/Debug.Windows.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/Debug.Windows.cs b/src/mscorlib/src/System/Diagnostics/Debug.Windows.cs new file mode 100644 index 0000000000..095e9b6985 --- /dev/null +++ b/src/mscorlib/src/System/Diagnostics/Debug.Windows.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Diagnostics +{ + public static partial class Debug + { + private static void ShowAssertDialog(string stackTrace, string message, string detailMessage) + { + if (Debugger.IsAttached) + { + Debugger.Break(); + } + else + { + // 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); + } + } + + private static void WriteCore(string message) + { + // really huge messages mess up both VS and dbmon, so we chop it up into + // reasonable chunks if it's too big. This is the number of characters + // that OutputDebugstring chunks at. + const int WriteChunkLength = 4091; + + // We don't want output from multiple threads to be interleaved. + lock (s_ForLock) + { + if (message == null || message.Length <= WriteChunkLength) + { + WriteToDebugger(message); + } + else + { + int offset; + for (offset = 0; offset < message.Length - WriteChunkLength; offset += WriteChunkLength) + { + WriteToDebugger(message.Substring(offset, WriteChunkLength)); + } + WriteToDebugger(message.Substring(offset)); + } + } + } + + private static void WriteToDebugger(string message) + { + if (Debugger.IsLogging()) + { + Debugger.Log(0, null, message); + } + else + { + Interop.Kernel32.OutputDebugString(message ?? string.Empty); + } + } + } +} |