Skip to content

Commit 3f711d3

Browse files
authored
Cleanup dead code (#7353)
2 parents 2240138 + 0b154e6 commit 3f711d3

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/Adapter/MSTestAdapter.PlatformServices/Execution/TypeCache.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ private MethodInfo GetMethodInfoForTestMethod(TestMethod testMethod, TestClassIn
687687

688688
private static MethodInfo? GetMethodInfoUsingManagedNameHelper(TestMethod testMethod, TestClassInfo testClassInfo, bool discoverInternals)
689689
{
690-
MethodBase? methodBase = null;
690+
MethodInfo? testMethodInfo = null;
691691
try
692692
{
693693
// testMethod.MethodInfo can be null if 'TestMethod' instance crossed app domain boundaries.
@@ -696,24 +696,12 @@ private MethodInfo GetMethodInfoForTestMethod(TestMethod testMethod, TestClassIn
696696
// In addition, it also happens when deployment items are used and app domain is disabled.
697697
// We explicitly set it to null in this case because the original MethodInfo calculated during discovery cannot be used because
698698
// it points to the type loaded from the assembly in bin instead of from deployment directory.
699-
methodBase = testMethod.MethodInfo ?? ManagedNameHelper.GetMethod(testClassInfo.Parent.Assembly, testMethod.ManagedTypeName!, testMethod.ManagedMethodName!);
699+
testMethodInfo = testMethod.MethodInfo ?? ManagedNameHelper.GetMethod(testClassInfo.Parent.Assembly, testMethod.ManagedTypeName!, testMethod.ManagedMethodName!);
700700
}
701701
catch (InvalidManagedNameException)
702702
{
703703
}
704704

705-
MethodInfo? testMethodInfo = null;
706-
if (methodBase is MethodInfo mi)
707-
{
708-
testMethodInfo = mi;
709-
}
710-
else if (methodBase != null)
711-
{
712-
Type[] parameters = [.. methodBase.GetParameters().Select(i => i.ParameterType)];
713-
// TODO: Should we pass true for includeNonPublic?
714-
testMethodInfo = PlatformServiceProvider.Instance.ReflectionOperations.GetRuntimeMethod(methodBase.DeclaringType!, methodBase.Name, parameters, includeNonPublic: true);
715-
}
716-
717705
return testMethodInfo is null
718706
|| !testMethodInfo.HasCorrectTestMethodSignature(true, discoverInternals)
719707
? null

src/Adapter/MSTestAdapter.PlatformServices/Helpers/ManagedNameHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static void GetManagedNameAndHierarchy(MethodBase method, out string mana
112112
/// More information about <paramref name="managedTypeName"/> and <paramref name="managedMethodName"/> can be found in
113113
/// <see href="https://github.com/microsoft/vstest/blob/main/docs/RFCs/0017-Managed-TestCase-Properties.md">the RFC</see>.
114114
/// </remarks>
115-
public static MethodBase GetMethod(Assembly assembly, string managedTypeName, string managedMethodName)
115+
public static MethodInfo GetMethod(Assembly assembly, string managedTypeName, string managedMethodName)
116116
{
117117
Type type = assembly.GetType(managedTypeName, throwOnError: false, ignoreCase: false)
118118
?? throw new InvalidManagedNameException();

0 commit comments

Comments
 (0)