2
我有一個問題,我需要禁用一個特定的規則(在這種情況下CA1819:PropertiesShouldNotReturnArrays)生成的代碼。如果它是我自己的代碼,那麼我會在給定函數中添加一個SuppressMessage
屬性,就是這樣。顯然,我不能在生成的代碼中這樣做,因爲它會在下一個版本中丟失。如何在生成的代碼中禁用特定的FxCop規則?
自動生成的代碼:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class ListViewTable {
private ListViewTableRow[] itemsField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Row", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public ListViewTableRow[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
}
的Items
屬性生成
<Message TypeName="PropertiesShouldNotReturnArrays" Category="Microsoft.Performance" CheckId="CA1819" Status="Active" Created="2013-10-29 14:47:04Z" FixCategory="Breaking">
<Issue Certainty="50" Level="Warning" Path="D:\Projects\FlightPlanning\src\Core\FpesCustomControls" File="AoiSchema.cs" Line="32">Change 'ListViewTable.Items' to return a collection or make it a method.</Issue>
</Message>
從GUI還可以選擇「Suppress Message」並選擇「在壓縮文件「(而不是」在源「),具有相同的效果。 –
這個選項在哪裏?我在上下文菜單中沒有這個... – PMF
當我在CodeAnalysis窗口中右擊消息時,我有這個選項。但我做*不*具有「複製到」,只是一個「複製」,奇怪。你可能使用舊的FxCop插件而不是現在內置的CodeAnalysis? –