From 442339967251b52523d6bb97a828e520bae82252 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 8 Jun 2026 08:05:24 -0400 Subject: [PATCH] Revert "Skipping EDI in the runtime-async case as well (#128735)" This reverts commit 08db7a3764b764ebd8f09548ae711d31575d65d4. --- .../tests/StackTraceTests.cs | 32 ------------------- .../src/System/Diagnostics/StackTrace.cs | 4 +-- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.cs b/src/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.cs index 1145a073e73d65..38b974da105135 100644 --- a/src/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.cs +++ b/src/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.cs @@ -66,14 +66,6 @@ public static async Task Test2(int i) { throw new NullReferenceException("Exception from Test2"); } - - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] -#line 1 "EdiOuter.cs" - public static async Task EdiOuter() - { - await V2Methods.EdiMiddle(); - } } public class V2Methods @@ -214,22 +206,6 @@ public static async Task Baz() if (Random.Shared.Next(1) == 100) await Task.Yield(); throw new Exception("Exception from Baz method."); } - - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(true)] -#line 1 "EdiMiddle.cs" - public static async Task EdiMiddle() - { - await EdiInner(); - } - - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(true)] -#line 1 "EdiInner.cs" - public static async Task EdiInner() - { - throw new InvalidOperationException("Exception from EdiInner"); - } } } #line default @@ -664,12 +640,6 @@ private static string FileInfoPattern(string fileLinePattern) => @"V2Methods\.Baz\(\)" + FileInfoPattern(@".*Baz.*\.cs:line 4"), @"V2Methods\.Bux\(\)" + FileInfoPattern(@".*Bux.*\.cs:line 6") }}, - { "EdiOuter", new[] { - @"Exception from EdiInner", - @"V2Methods\.EdiInner\(\)" + FileInfoPattern(@".*EdiInner.*\.cs:line 3"), - @"V2Methods\.EdiMiddle\(\)" + FileInfoPattern(@".*EdiMiddle.*\.cs:line 3"), - @"V1Methods.*EdiOuter" - }}, }; public static IEnumerable Ctor_Async_TestData() @@ -679,7 +649,6 @@ public static IEnumerable Ctor_Async_TestData() yield return new object[] { () => V2Methods.Quux(), MethodExceptionStrings["Quux"] }; yield return new object[] { () => V2Methods.Quuux(), MethodExceptionStrings["Quuux"] }; yield return new object[] { () => V2Methods.Bux(), MethodExceptionStrings["Bux"] }; - yield return new object[] { () => V1Methods.EdiOuter(), MethodExceptionStrings["EdiOuter"] }; } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsRuntimeAsyncSupported))] @@ -708,7 +677,6 @@ public async Task ToString_Async(Func asyncMethod, string[] expectedPatter Assert.True(match.Success, $"Could not find expected pattern '{pattern}' in exception text:\n{exceptionText} starting at index {startIndex}."); startIndex = match.Index + match.Length; } - Assert.DoesNotContain("--- End of stack trace from previous location ---", exceptionText); } [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs index 58799d118b9069..c2270b78fe8d48 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs @@ -237,11 +237,11 @@ internal void ToString(TraceFormat traceFormat, StringBuilder sb) sb.Append(" ").Append(word_At).Append(' '); - bool isAsync = (mb.MethodImplementationFlags & MethodImplAttributes.Async) != 0; + bool isAsync = false; Type? declaringType = mb.DeclaringType; string methodName = mb.Name; bool methodChanged = false; - if (!isAsync && declaringType != null && IsDefinedSafe(declaringType, typeof(CompilerGeneratedAttribute), inherit: false)) + if (declaringType != null && IsDefinedSafe(declaringType, typeof(CompilerGeneratedAttribute), inherit: false)) { isAsync = declaringType.IsAssignableTo(typeof(IAsyncStateMachine)); if (isAsync || declaringType.IsAssignableTo(typeof(IEnumerator)))