From 33ce0e2538172287ffea9ad28b5df2cde6de2f60 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Wed, 17 Jan 2018 17:52:06 +0000 Subject: [PATCH] Skip EDI boundary for async (#15781) --- src/mscorlib/src/System/Diagnostics/Stacktrace.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs index cc6f000..d71ba61 100644 --- a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs +++ b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs @@ -498,12 +498,16 @@ namespace System.Diagnostics sb.AppendFormat(CultureInfo.InvariantCulture, " {0} ", word_At); - Type t = mb.DeclaringType; + Type declaringType = mb.DeclaringType; + bool isAsync = (declaringType != null && + declaringType.IsDefined(typeof(CompilerGeneratedAttribute)) && + typeof(IAsyncStateMachine).IsAssignableFrom(declaringType)); + // if there is a type (non global method) print it - if (t != null) + if (declaringType != null) { // Append t.FullName, replacing '+' with '.' - string fullName = t.FullName; + string fullName = declaringType.FullName; for (int i = 0; i < fullName.Length; i++) { char ch = fullName[i]; @@ -594,7 +598,8 @@ namespace System.Diagnostics } } - if (sf.GetIsLastFrameFromForeignExceptionStackTrace()) + if (sf.GetIsLastFrameFromForeignExceptionStackTrace() && + !isAsync) // Skip EDI boundary for async { sb.Append(Environment.NewLine); sb.Append(SR.Exception_EndStackTraceFromPreviousThrow); -- 2.7.4