private static bool Prefix(ref string __result) { const int baseSkip = 1; // const int skipNoise = 4;//4; var skipCalls = 0; var rawStacktrace = new StackTrace(); for (var i = 0; i < rawStacktrace.FrameCount; i++) { var frame = rawStacktrace.GetFrame(i); var method = frame.GetMethod(); if (method == null) { break; } if (method.DeclaringType == typeof(Patch_StacktraceUtility) || method.DeclaringType == typeof(StackTraceUtility) || method.DeclaringType == typeof(Debug) || method.DeclaringType?.Name == "DebugLogHandler") { skipCalls += 1; continue; } break; } var trace = new StackTrace(baseSkip + skipCalls, true); trace = new EnhancedStackTrace(trace); __result = trace.ToString(); Hyperlinks.FixStacktrace(ref __result); StacktraceMarkerUtil.AddMarker(ref __result); return(false); }
private static bool Prefix(ref string __result) { const int skip = 1; const int skipNoise = 4; //4; StackTrace trace = new StackTrace(skip + skipNoise, true); trace = new EnhancedStackTrace(trace); __result = trace.ToString(); Hyperlinks.FixStacktrace(ref __result); StacktraceMarkerUtil.AddMarker(ref __result); return(false); }
public static bool ExceptionGetStackTrace(Exception __instance, ref string __result) { try { var exStackTrace = new EnhancedStackTrace(__instance); __result = exStackTrace.ToString(); return(false); } catch (Exception) { return(true); } }
public async Task Current() { // Arrange EnhancedStackTrace est = null; // Act await Task.Run(() => est = EnhancedStackTrace.Current()).ConfigureAwait(false); // Assert var stackTrace = est.ToString(); stackTrace = ReplaceLineEndings.Replace(stackTrace, ""); var trace = stackTrace.Split(Environment.NewLine); Assert.Equal( new[] { " at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)", " at bool System.Threading.ThreadPoolWorkQueue.Dispatch()" }, trace); }
public async Task Current() { // Arrange EnhancedStackTrace est = null; // Act await Task.Run(() => est = EnhancedStackTrace.Current()).ConfigureAwait(false); // Assert var stackTrace = est.ToString(); stackTrace = ReplaceLineEndings.Replace(stackTrace, ""); var trace = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None) // Remove Full framework entries .Where(s => !s.StartsWith(" at bool System.Threading._ThreadPoolWaitCallbac") && !s.StartsWith(" at void System.Threading.Tasks.Task.System.Thre")); Assert.Equal( new[] { " at bool System.Threading.ThreadPoolWorkQueue.Dispatch()" }, trace); }