Avoid boxing array enumerator in StackTrace.TryResolveStateMachineMethod (#66836)
authorStephen Toub <stoub@microsoft.com>
Sat, 19 Mar 2022 12:19:58 +0000 (08:19 -0400)
committerGitHub <noreply@github.com>
Sat, 19 Mar 2022 12:19:58 +0000 (08:19 -0400)
src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs

index c86c3be..81b0e58 100644 (file)
@@ -418,7 +418,7 @@ namespace System.Diagnostics
 
             foreach (MethodInfo candidateMethod in methods)
             {
-                IEnumerable<StateMachineAttribute>? attributes = candidateMethod.GetCustomAttributes<StateMachineAttribute>(inherit: false);
+                StateMachineAttribute[]? attributes = (StateMachineAttribute[])Attribute.GetCustomAttributes(candidateMethod, typeof(StateMachineAttribute), inherit: false);
                 if (attributes == null)
                 {
                     continue;