我正在尝试查看一个给定方法是否带有属性(该属性为
有没有一种方法可以实现这个功能?
NUnit.Framework.TestAttribute
),但我需要能够检查该属性,无论属性的版本如何。目前,我在项目中使用反射的是 nunit.framework.dll
版本 2.6.2,而在测试中使用的是 dll 的版本 2.6.0。反射未找到该属性。有没有一种方法可以实现这个功能?
bool isTest = method.GetCustomAttributes(typeof(TestAttribute), true).Length > 0;
没有访问正确版本的TestAttribute
dll,怎么办?
其中,方法的类型为MethodInfo
。