Skip to content

Commit

Permalink
remove _test reflection from nunit (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Sep 4, 2024
1 parent 6032c96 commit 2b1e7bc
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/Verify.NUnit/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string>? GetParameterNames(this TestAdapter adapter)
{
var method = adapter.Method!;
Expand Down

0 comments on commit 2b1e7bc

Please sign in to comment.