/// <summary> /// A single interpreted frame might be represented by multiple subsequent Interpreter.Run CLR frames. /// This method filters out the duplicate CLR frames. /// </summary> public static IEnumerable <StackFrame> GroupStackFrames(IEnumerable <StackFrame> stackTrace) { bool inInterpretedFrame = false; foreach (StackFrame frame in stackTrace) { MethodBase method = frame.GetMethod(); // mono sets the method to null for dynamic methods // IsInterpretedFrame doesn't allow null methods if (method == null) { continue; } if (InterpretedFrame.IsInterpretedFrame(method)) { if (inInterpretedFrame) { continue; } inInterpretedFrame = true; } else { inInterpretedFrame = false; } yield return(frame); } }
/// <summary> /// A single interpreted frame might be represented by multiple subsequent Interpreter.Run CLR frames. /// This method filters out the duplicate CLR frames. /// </summary> public static IEnumerable <StackFrame> GroupStackFrames(IEnumerable <StackFrame> stackTrace) { bool inInterpretedFrame = false; foreach (StackFrame frame in stackTrace) { if (InterpretedFrame.IsInterpretedFrame(frame.GetMethod())) { if (inInterpretedFrame) { continue; } inInterpretedFrame = true; } else { inInterpretedFrame = false; } yield return(frame); } }