Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/Adapter/MSTestAdapter.PlatformServices/Execution/TypeCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ private MethodInfo GetMethodInfoForTestMethod(TestMethod testMethod, TestClassIn

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

MethodInfo? testMethodInfo = null;
if (methodBase is MethodInfo mi)
{
testMethodInfo = mi;
}
else if (methodBase != null)
{
Type[] parameters = [.. methodBase.GetParameters().Select(i => i.ParameterType)];
// TODO: Should we pass true for includeNonPublic?
testMethodInfo = PlatformServiceProvider.Instance.ReflectionOperations.GetRuntimeMethod(methodBase.DeclaringType!, methodBase.Name, parameters, includeNonPublic: true);
}

return testMethodInfo is null
|| !testMethodInfo.HasCorrectTestMethodSignature(true, discoverInternals)
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static void GetManagedNameAndHierarchy(MethodBase method, out string mana
/// More information about <paramref name="managedTypeName"/> and <paramref name="managedMethodName"/> can be found in
/// <see href="https://github.com/microsoft/vstest/blob/main/docs/RFCs/0017-Managed-TestCase-Properties.md">the RFC</see>.
/// </remarks>
public static MethodBase GetMethod(Assembly assembly, string managedTypeName, string managedMethodName)
public static MethodInfo GetMethod(Assembly assembly, string managedTypeName, string managedMethodName)
{
Type type = assembly.GetType(managedTypeName, throwOnError: false, ignoreCase: false)
?? throw new InvalidManagedNameException();
Expand Down