From f68fd345aa1ed6d955bfa62dd860be5750351718 Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Thu, 13 May 2021 09:20:09 +0200 Subject: [PATCH] Reverting an unintended breaking-change. (#826) Reverting an unintended breaking change in reflection. Thank you, @azchohfi, for reporting it; this makes #824 unnecessary. --- .../MSTest.CoreAdapter/Execution/TestMethodInfo.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs index 6a3e6b9f71..1d4d0d13bb 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs @@ -93,7 +93,9 @@ public Attribute[] GetAllAttributes(bool inherit) } public TAttributeType[] GetAttributes(bool inherit) - where TAttributeType : Attribute => ReflectHelper.GetAttributes(this.TestMethod, inherit); + where TAttributeType : Attribute + => ReflectHelper.GetAttributes(this.TestMethod, inherit) + ?? EmptyHolder.Array; /// /// Execute test method. Capture failures, handle async and return result. @@ -784,5 +786,10 @@ void executeAsyncAction() return timeoutResult; } } + + private static class EmptyHolder + { + internal static readonly T[] Array = new T[0]; + } } }