public static int GetStackTraceDepth(string currentStackTrace) { var stackTraceInfo = GetStackTraceInfo(currentStackTrace); var methodCallMatches = StackRegex.Matches(stackTraceInfo); return methodCallMatches.Count; }