我遇到了一个问题,我需要为生成的代码禁用某个规则(在本例中为 CA1819:PropertiesShouldNotReturnArrays)。如果是我自己的代码,我会SuppressMessage
在给定的函数中添加一个属性,就是这样。显然,我不能在生成的代码中这样做,因为它会在下一次构建时丢失。
自动生成的代码:
[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>