【发布时间】:2013-11-25 17:14:40
【问题描述】:
我正在尝试创建一个单元测试,该单元测试只会对不抑制相应消息的类型失败。但是,我无法在单元测试中访问任何类型的 SuppressMessage 属性。是否可以在运行时访问 SuppressMessage 属性?我已经包含了我的单元测试的简化版本。
[System.Diagnostics.CodeAnalysis.SuppressMessage("Foo", "Bar")]
public interface IMyInterface { }
public void UnitTest()
{
var getCustomAttributes = typeof(IMyInterface).GetCustomAttributes(); //Returns an empty array
//Skip check if message should be suppressed
}
【问题讨论】:
标签: c# reflection attributes suppressmessage