Skip to content
Merged
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,17 @@ private ITestCaseFilterExpression GetTestCaseFilterFromDiscoveryContext(IDiscove
MethodInfo methodGetTestCaseFilter = context.GetType().GetRuntimeMethod("GetTestCaseFilter", new[] { typeof(IEnumerable<string>), typeof(Func<string, TestProperty>) });
return (ITestCaseFilterExpression)methodGetTestCaseFilter?.Invoke(context, new object[] { this.supportedProperties.Keys, (Func<string, TestProperty>)this.PropertyProvider });
}
catch (TargetInvocationException ex)
catch (Exception ex)
{
throw ex.InnerException;
// In case of UWP .Net Native Tool Chain compilation. Invoking methods via Reflection doesn't work, hence discovery always fails.
// Hence throwing exception only if it is of type TestPlatformFormatException
if (ex.InnerException is TestPlatformFormatException)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK platform throws only testplatformformatexception, but instead of relying entirely on this fact, we can skip exception specifically when it is thrown because of reflection not working. In other cases, lets throw error.
Skipping all exceptions other than testplatformformatexception might skip unexpected exceptions in addition to reflection related exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case any other exception is thrown, which is very unlikely, we should continue with discovery rather than not doing at all, because platform went wrong, which is why I'm only throwing error if it platform exception

{
throw ex.InnerException;
}
}

return null;
}
}
}