private static bool Prefix(StackTrace stackTrace, ref string __result) { __result = new EnhancedStackTrace(stackTrace).ToString(); Hyperlinks.FixStacktrace(ref __result); StacktraceMarkerUtil.AddMarker(ref __result); return(false); }
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 void Postfix(object __instance, ref string __result) { if (__instance is Exception ex) { __result = ex.ToStringDemystified(); Hyperlinks.FixStacktrace(ref __result); StacktraceMarkerUtil.AddMarker(ref __result); } }
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 void Apply(ref string stacktrace) { try { var str = ""; var lines = stacktrace.Split('\n'); var settings = DemystifySettings.instance; var foundPrefix = false; foreach (var t in lines) { var line = t; if (StacktraceMarkerUtil.IsPrefix(line)) { StacktraceMarkerUtil.RemoveMarkers(ref line); if (!string.IsNullOrEmpty(settings.Separator)) { str += settings.Separator + "\n"; } foundPrefix = true; } if (foundPrefix && settings.UseSyntaxHighlighting) { SyntaxHighlighting.AddSyntaxHighlighting(ref line); } str += line.Trim(); if (!str.EndsWith("\n")) { str += "\n"; } } if (!string.IsNullOrWhiteSpace(str)) { stacktrace = str; } } catch // (Exception e) { // ignore } }
public static void Apply(ref string stacktrace) { try { using (new ProfilerMarker("Demystify.Apply").Auto()) { string[] lines = null; using (new ProfilerMarker("Split Lines").Auto()) lines = stacktrace.Split('\n'); var settings = DemystifySettings.instance; var foundPrefix = false; foreach (var t in lines) { var line = t; using (new ProfilerMarker("Remove Markers").Auto()) { if (StacktraceMarkerUtil.IsPrefix(line)) { StacktraceMarkerUtil.RemoveMarkers(ref line); if (!string.IsNullOrEmpty(settings.Separator)) { builder.AppendLine(settings.Separator); } foundPrefix = true; } } if (foundPrefix && settings.UseSyntaxHighlighting) { SyntaxHighlighting.AddSyntaxHighlighting(ref line); } var l = line.Trim(); if (!string.IsNullOrEmpty(l)) { if (!l.EndsWith("\n")) { builder.AppendLine(l); } else { builder.Append(l); } } } var res = builder.ToString(); if (!string.IsNullOrWhiteSpace(res)) { stacktrace = res; } builder.Clear(); } } catch // (Exception e) { // ignore } }