From 2b1e7bcd94a1998cb6d78bba6ebeb993e1cb62c4 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 5 Sep 2024 07:51:26 +1000 Subject: [PATCH] remove _test reflection from nunit (#1283) --- src/Verify.NUnit/Extensions.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Verify.NUnit/Extensions.cs b/src/Verify.NUnit/Extensions.cs index 4f0ba8927d..e6054fb5cc 100644 --- a/src/Verify.NUnit/Extensions.cs +++ b/src/Verify.NUnit/Extensions.cs @@ -13,8 +13,7 @@ public static IMethodInfo GetTestMethod(this TestAdapter adapter) public static bool TryGetParent(this TestAdapter adapter, [NotNullWhen(true)] out ITest? parent) { - var test = adapter.GetTest(); - parent = test.Parent; + parent = adapter.Parent; if (parent is ParameterizedMethodSuite methodSuite) { parent = methodSuite.Parent; @@ -23,12 +22,6 @@ public static bool TryGetParent(this TestAdapter adapter, [NotNullWhen(true)] ou return parent != null; } - static FieldInfo testField = typeof(TestAdapter) - .GetField("_test", BindingFlags.Instance | BindingFlags.NonPublic)!; - - public static Test GetTest(this TestAdapter adapter) => - (Test) testField.GetValue(adapter)!; - public static IReadOnlyList? GetParameterNames(this TestAdapter adapter) { var method = adapter.Method!;