diff --git a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs index ff81cc7..45cbe1d 100644 --- a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs +++ b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs @@ -19,7 +19,7 @@ namespace System.Diagnostics { public partial class EnhancedStackTrace { - private static readonly Type StackTraceHiddenAttibuteType = Type.GetType("System.Diagnostics.StackTraceHiddenAttribute", false); + private static readonly Type StackTraceHiddenAttributeType = Type.GetType("System.Diagnostics.StackTraceHiddenAttribute", false); private static List GetFrames(Exception exception) { @@ -625,7 +625,24 @@ namespace System.Diagnostics private static bool ShowInStackTrace(MethodBase method) { Debug.Assert(method != null); + + if (StackTraceHiddenAttributeType != null) + { + // Don't show any methods marked with the StackTraceHiddenAttribute + // https://github.com/dotnet/coreclr/pull/14652 + if (IsStackTraceHidden(method)) + { + return false; + } + } + var type = method.DeclaringType; + + if (type == null) + { + return true; + } + if (type == typeof(Task<>) && method.Name == "InnerInvoke") { return false; @@ -652,22 +669,7 @@ namespace System.Diagnostics } } - if (StackTraceHiddenAttibuteType != null) - { - // Don't show any methods marked with the StackTraceHiddenAttribute - // https://github.com/dotnet/coreclr/pull/14652 - if (IsStackTraceHidden(method)) - { - return false; - } - } - - if (type == null) - { - return true; - } - - if (StackTraceHiddenAttibuteType != null) + if (StackTraceHiddenAttributeType != null) { // Don't show any types marked with the StackTraceHiddenAttribute // https://github.com/dotnet/coreclr/pull/14652 @@ -710,7 +712,7 @@ namespace System.Diagnostics { if (!memberInfo.Module.Assembly.ReflectionOnly) { - return memberInfo.GetCustomAttributes(StackTraceHiddenAttibuteType, false).Length != 0; + return memberInfo.GetCustomAttributes(StackTraceHiddenAttributeType, false).Length != 0; } EnumerableIList attributes; @@ -726,7 +728,7 @@ namespace System.Diagnostics foreach (var attribute in attributes) { // reflection-only attribute, match on name - if (attribute.AttributeType.FullName == StackTraceHiddenAttibuteType.FullName) + if (attribute.AttributeType.FullName == StackTraceHiddenAttributeType.FullName) { return true; }