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 c86c3be39fe76e..81b0e58b12dc57 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs @@ -418,7 +418,7 @@ private static bool TryResolveStateMachineMethod(ref MethodBase method, out Type foreach (MethodInfo candidateMethod in methods) { - IEnumerable? attributes = candidateMethod.GetCustomAttributes(inherit: false); + StateMachineAttribute[]? attributes = (StateMachineAttribute[])Attribute.GetCustomAttributes(candidateMethod, typeof(StateMachineAttribute), inherit: false); if (attributes == null) { continue;