Example #1
0
        public static DebugProvider SetProvider(DebugProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            return(Interlocked.Exchange(ref s_provider, provider));
        }
Example #2
0
        private static string FormatAssert(string stackTrace, string message, string detailMessage)
        {
            string newLine = DebugProvider.GetIndentString() + Environment.NewLine;

            return(SR.DebugAssertBanner + newLine
                   + SR.DebugAssertShortMessage + newLine
                   + message + newLine
                   + SR.DebugAssertLongMessage + newLine
                   + detailMessage + newLine
                   + stackTrace);
        }
Example #3
0
        internal static void ContractFailure(string message, string detailMessage, string failureKindMessage)
        {
            string stackTrace;

            try
            {
                stackTrace = new StackTrace(2, true).ToString(System.Diagnostics.StackTrace.TraceFormat.Normal);
            }
            catch
            {
                stackTrace = "";
            }
            s_provider.WriteAssert(stackTrace, message, detailMessage);
            DebugProvider.FailCore(stackTrace, message, detailMessage, failureKindMessage);
        }
Example #4
0
        private void Write(string?message, bool useLogFile)
        {
            message ??= string.Empty;

            if (NeedIndent && message.Length != 0)
            {
                WriteIndent();
            }

            DebugProvider.WriteCore(message);

            if (useLogFile && !string.IsNullOrEmpty(LogFileName))
            {
                WriteToLogFile(message);
            }
        }
Example #5
0
 /// <devdoc>
 ///    <para>
 ///       Emits or displays messages and a stack trace for an assertion that
 ///       always fails.
 ///    </para>
 /// </devdoc>
 public override void Fail(string message, string detailMessage)
 {
     string stackTrace;
     try
     {
         stackTrace = new StackTrace(fNeedFileInfo:true).ToString();
     }
     catch
     {
         stackTrace = "";
     }
     WriteAssert(stackTrace, message, detailMessage);
     if (AssertUiEnabled)
     {
         DebugProvider.FailCore(stackTrace, message, detailMessage, "Assertion Failed");
     }
 }
Example #6
0
 public static DebugProvider SetProvider(DebugProvider provider !!)
 {
     return(Interlocked.Exchange(ref s_provider, provider));
Example #7
0
        public static DebugProvider SetProvider(DebugProvider provider)
        {
            ArgumentNullException.ThrowIfNull(provider);

            return(Interlocked.Exchange(ref s_provider, provider));
        }