3
我正在嘗試創建一個單元測試,該類測試只對不禁止相應消息的類型失敗。但是,我無法在單元測試中訪問我的任何類型的SuppressMessage屬性。運行時是否可以訪問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
}