in src/Adapter/MSTest.CoreAdapter/Discovery/TestMethodValidator.cs [51:85]
internal virtual bool IsValidTestMethod(MethodInfo testMethodInfo, Type type, ICollection<string> warnings)
{
if (!this.reflectHelper.IsAttributeDefined(testMethodInfo, typeof(TestMethodAttribute), false)
&& !this.reflectHelper.HasAttributeDerivedFrom(testMethodInfo, typeof(TestMethodAttribute), false))
{
return false;
}
// Generic method Definitions are not valid.
if (testMethodInfo.IsGenericMethodDefinition)
{
var message = string.Format(CultureInfo.CurrentCulture, Resource.UTA_ErrorGenericTestMethod, testMethodInfo.DeclaringType.FullName, testMethodInfo.Name);
warnings.Add(message);
return false;
}
var isAccessible = testMethodInfo.IsPublic
|| (this.discoverInternals && testMethodInfo.IsAssembly);
// Todo: Decide whether parameter count matters.
// The isGenericMethod check below id to verify that there are no closed generic methods slipping through.
// Closed generic methods being GenericMethod<int> and open being GenericMethod<T>.
var isValidTestMethod = isAccessible && !testMethodInfo.IsAbstract && !testMethodInfo.IsStatic
&& !testMethodInfo.IsGenericMethod
&& testMethodInfo.IsVoidOrTaskReturnType();
if (!isValidTestMethod)
{
var message = string.Format(CultureInfo.CurrentCulture, Resource.UTA_ErrorIncorrectTestMethodSignature, type.FullName, testMethodInfo.Name);
warnings.Add(message);
return false;
}
return true;
}