Skip to content
Merged
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
19 changes: 14 additions & 5 deletions src/Adapter/MSTest.TestAdapter/Execution/TypeCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,9 +656,16 @@ private MethodInfo GetMethodInfoForTestMethod(TestMethod testMethod, TestClassIn

private static MethodInfo? GetMethodInfoUsingManagedNameHelper(TestMethod testMethod, TestClassInfo testClassInfo, bool discoverInternals)
{
MethodInfo? testMethodInfo = null;
var methodBase = ManagedNameHelper.GetMethod(testClassInfo.Parent.Assembly, testMethod.ManagedTypeName!, testMethod.ManagedMethodName!);
MethodBase? methodBase = null;
try
{
methodBase = ManagedNameHelper.GetMethod(testClassInfo.Parent.Assembly, testMethod.ManagedTypeName!, testMethod.ManagedMethodName!);
}
catch (InvalidManagedNameException)
{
}

MethodInfo? testMethodInfo = null;
if (methodBase is MethodInfo mi)
{
testMethodInfo = mi;
Expand All @@ -669,9 +676,11 @@ private MethodInfo GetMethodInfoForTestMethod(TestMethod testMethod, TestClassIn
testMethodInfo = methodBase.DeclaringType!.GetRuntimeMethod(methodBase.Name, parameters);
}

testMethodInfo = testMethodInfo?.HasCorrectTestMethodSignature(true, discoverInternals) ?? false
? testMethodInfo
: null;
if (testMethodInfo is null
|| !testMethodInfo.HasCorrectTestMethodSignature(true, discoverInternals))
{
return null;
}

return testMethodInfo;
}
Expand Down