public override AssertFilters AssertFailure(String condition, String message, StackTrace location, StackTrace.TraceFormat stackTraceFormat, String windowTitle) { return((AssertFilters)Assert.ShowDefaultAssertDialog(condition, message, location.ToString(stackTraceFormat), windowTitle)); }
internal static void Fail(String conditionString, String message, String windowTitle, int exitCode, StackTrace.TraceFormat stackTraceFormat, int numStackFramesToSkip) { // get the stacktrace StackTrace st = new StackTrace(numStackFramesToSkip, true); AssertFilters iResult = Filter.AssertFailure(conditionString, message, st, stackTraceFormat, windowTitle); if (iResult == AssertFilters.FailDebug) { if (Debugger.IsAttached == true) { Debugger.Break(); } else { if (Debugger.Launch() == false) { throw new InvalidOperationException( Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed")); } } } else if (iResult == AssertFilters.FailTerminate) { // We want to exit the Silverlight application, after displaying a message. // Our best known way to emulate this is to exit the process with a known // error code. Jolt may not be prepared for an appdomain to be unloaded. Environment._Exit(exitCode); } }
internal static void Fail(String conditionString, String message, int exitCode, StackTrace.TraceFormat stackTraceFormat) { Fail(conditionString, message, null, exitCode, stackTraceFormat, 0); }
// Token: 0x0600325C RID: 12892 RVA: 0x000C1298 File Offset: 0x000BF498 internal string ToString(StackTrace.TraceFormat traceFormat) { bool flag = true; string arg = "at"; string format = "in {0}:line {1}"; if (traceFormat != StackTrace.TraceFormat.NoResourceLookup) { arg = Environment.GetResourceString("Word_At"); format = Environment.GetResourceString("StackTrace_InFileLineNumber"); } bool flag2 = true; StringBuilder stringBuilder = new StringBuilder(255); for (int i = 0; i < this.m_iNumOfFrames; i++) { StackFrame frame = this.GetFrame(i); MethodBase method = frame.GetMethod(); if (method != null) { if (flag2) { flag2 = false; } else { stringBuilder.Append(Environment.NewLine); } stringBuilder.AppendFormat(CultureInfo.InvariantCulture, " {0} ", arg); Type declaringType = method.DeclaringType; if (declaringType != null) { stringBuilder.Append(declaringType.FullName.Replace('+', '.')); stringBuilder.Append("."); } stringBuilder.Append(method.Name); if (method is MethodInfo && ((MethodInfo)method).IsGenericMethod) { Type[] genericArguments = ((MethodInfo)method).GetGenericArguments(); stringBuilder.Append("["); int j = 0; bool flag3 = true; while (j < genericArguments.Length) { if (!flag3) { stringBuilder.Append(","); } else { flag3 = false; } stringBuilder.Append(genericArguments[j].Name); j++; } stringBuilder.Append("]"); } stringBuilder.Append("("); ParameterInfo[] parameters = method.GetParameters(); bool flag4 = true; for (int k = 0; k < parameters.Length; k++) { if (!flag4) { stringBuilder.Append(", "); } else { flag4 = false; } string str = "<UnknownType>"; if (parameters[k].ParameterType != null) { str = parameters[k].ParameterType.Name; } stringBuilder.Append(str + " " + parameters[k].Name); } stringBuilder.Append(")"); if (flag && frame.GetILOffset() != -1) { string text = null; try { text = frame.GetFileName(); } catch (NotSupportedException) { flag = false; } catch (SecurityException) { flag = false; } if (text != null) { stringBuilder.Append(' '); stringBuilder.AppendFormat(CultureInfo.InvariantCulture, format, text, frame.GetFileLineNumber()); } } if (frame.GetIsLastFrameFromForeignExceptionStackTrace()) { stringBuilder.Append(Environment.NewLine); stringBuilder.Append(Environment.GetResourceString("Exception_EndStackTraceFromPreviousThrow")); } } } if (traceFormat == StackTrace.TraceFormat.TrailingNewLine) { stringBuilder.Append(Environment.NewLine); } return(stringBuilder.ToString()); }
// Called when an assert fails. This should be overridden with logic which // determines whether the program should terminate or not. Typically this // is done by asking the user. // // The windowTitle can be null. abstract public AssertFilters AssertFailure(String condition, String message, StackTrace location, StackTrace.TraceFormat stackTraceFormat, String windowTitle);
internal static void Fail(String conditionString, String message, String windowTitle, int exitCode, StackTrace.TraceFormat stackTraceFormat, int numStackFramesToSkip) { // get the stacktrace StackTrace st = new StackTrace(numStackFramesToSkip, true); AssertFilters iResult = Filter.AssertFailure(conditionString, message, st, stackTraceFormat, windowTitle); if (iResult == AssertFilters.FailDebug) { if (Debugger.IsAttached == true) { Debugger.Break(); } else { if (Debugger.Launch() == false) { throw new InvalidOperationException( Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed")); } } } else if (iResult == AssertFilters.FailTerminate) { #if FEATURE_CORECLR // We want to exit the Silverlight application, after displaying a message. // Our best known way to emulate this is to exit the process with a known // error code. Jolt may not be prepared for an appdomain to be unloaded. Environment._Exit(exitCode); #else // This assert dialog will be common for code contract failures. If a code contract failure // occurs on an end user machine, we believe the right experience is to do a FailFast, which // will report this error via Watson, so someone could theoretically fix the bug. // However, in CLR v4, Environment.FailFast when a debugger is attached gives you an MDA // saying you've hit a bug in the runtime or unsafe managed code, and this is most likely caused // by heap corruption or a stack imbalance from COM Interop or P/Invoke. That extremely // misleading error isn't right, and we can temporarily work around this by using Environment.Exit // if a debugger is attached. The right fix is to plumb FailFast correctly through our native // Watson code, adding in a TypeOfReportedError for fatal managed errors. if (Debugger.IsAttached) { Environment._Exit(exitCode); } else { Environment.FailFast(message, unchecked ((uint)exitCode)); } #endif } }
internal static void Fail(string conditionString, string message, string windowTitle, int exitCode, StackTrace.TraceFormat stackTraceFormat, int numStackFramesToSkip) { StackTrace location = new StackTrace(numStackFramesToSkip, true); switch (Assert.Filter.AssertFailure(conditionString, message, location, stackTraceFormat, windowTitle)) { case AssertFilters.FailDebug: if (Debugger.IsAttached) { Debugger.Break(); break; } if (Debugger.Launch()) { break; } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed")); case AssertFilters.FailTerminate: if (Debugger.IsAttached) { Environment._Exit(exitCode); break; } Environment.FailFast(message, (uint)exitCode); break; } }
internal static void Fail(string conditionString, string message, int exitCode, StackTrace.TraceFormat stackTraceFormat) { Assert.Fail(conditionString, message, (string)null, exitCode, stackTraceFormat, 0); }
internal static void Fail(String conditionString, String message, String windowTitle, int exitCode, StackTrace.TraceFormat stackTraceFormat, int numStackFramesToSkip) { // get the stacktrace StackTrace st = new StackTrace(numStackFramesToSkip, true); AssertFilters iResult = Filter.AssertFailure(conditionString, message, st, stackTraceFormat, windowTitle); if (iResult == AssertFilters.FailDebug) { if (Debugger.IsAttached == true) { Debugger.Break(); } else { if (Debugger.Launch() == false) { throw new InvalidOperationException( Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed")); } } } else if (iResult == AssertFilters.FailTerminate) { #if FEATURE_CORECLR // We want to exit the Silverlight application, after displaying a message. // Our best known way to emulate this is to exit the process with a known // error code. Jolt may not be prepared for an appdomain to be unloaded. Environment._Exit(exitCode); #else // This assert dialog will be common for code contract failures. If a code contract failure // occurs on an end user machine, we believe the right experience is to do a FailFast, which // will report this error via Watson, so someone could theoretically fix the if (Debugger.IsAttached) { Environment._Exit(exitCode); } else { Environment.FailFast(message, unchecked ((uint)exitCode)); } #endif } }
internal string ToString(StackTrace.TraceFormat traceFormat) { bool flag1 = true; string str1 = "at"; string format = "in {0}:line {1}"; if (traceFormat != StackTrace.TraceFormat.NoResourceLookup) { str1 = Environment.GetResourceString("Word_At"); format = Environment.GetResourceString("StackTrace_InFileLineNumber"); } bool flag2 = true; StringBuilder stringBuilder = new StringBuilder((int)byte.MaxValue); for (int index1 = 0; index1 < this.m_iNumOfFrames; ++index1) { StackFrame frame = this.GetFrame(index1); MethodBase method = frame.GetMethod(); if (method != (MethodBase)null) { if (flag2) { flag2 = false; } else { stringBuilder.Append(Environment.NewLine); } stringBuilder.AppendFormat((IFormatProvider)CultureInfo.InvariantCulture, " {0} ", (object)str1); Type declaringType = method.DeclaringType; if (declaringType != (Type)null) { stringBuilder.Append(declaringType.FullName.Replace('+', '.')); stringBuilder.Append("."); } stringBuilder.Append(method.Name); if (method is MethodInfo && method.IsGenericMethod) { Type[] genericArguments = method.GetGenericArguments(); stringBuilder.Append("["); int index2 = 0; bool flag3 = true; for (; index2 < genericArguments.Length; ++index2) { if (!flag3) { stringBuilder.Append(","); } else { flag3 = false; } stringBuilder.Append(genericArguments[index2].Name); } stringBuilder.Append("]"); } stringBuilder.Append("("); ParameterInfo[] parameters = method.GetParameters(); bool flag4 = true; for (int index2 = 0; index2 < parameters.Length; ++index2) { if (!flag4) { stringBuilder.Append(", "); } else { flag4 = false; } string str2 = "<UnknownType>"; if (parameters[index2].ParameterType != (Type)null) { str2 = parameters[index2].ParameterType.Name; } stringBuilder.Append(str2 + " " + parameters[index2].Name); } stringBuilder.Append(")"); if (flag1 && frame.GetILOffset() != -1) { string str2 = (string)null; try { str2 = frame.GetFileName(); } catch (NotSupportedException ex) { flag1 = false; } catch (SecurityException ex) { flag1 = false; } if (str2 != null) { stringBuilder.Append(' '); stringBuilder.AppendFormat((IFormatProvider)CultureInfo.InvariantCulture, format, (object)str2, (object)frame.GetFileLineNumber()); } } if (frame.GetIsLastFrameFromForeignExceptionStackTrace()) { stringBuilder.Append(Environment.NewLine); stringBuilder.Append(Environment.GetResourceString("Exception_EndStackTraceFromPreviousThrow")); } } } if (traceFormat == StackTrace.TraceFormat.TrailingNewLine) { stringBuilder.Append(Environment.NewLine); } return(stringBuilder.ToString()); }