我知道我遲到了這個但在這裏不用。
我猜這些警告都發出了代碼InitializeComponent
方法中?如果是這樣,那麼您是否考慮過修改位於Common7 \ IDE \ ItemTemplates文件夾中的模板文件?您可以在這些方法中添加GeneratedCode
屬性。由於該屬性將僅在其上設置,因此同一類中的所有其他代碼仍將通過代碼分析進行檢查。
下面是Form
設計文件的一個示例:
namespace $rootnamespace$
{
partial class $safeitemrootname$
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Windows Form Designer generated code", "1.0.0.0"), System.Diagnostics.DebuggerNonUserCode()]
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "$safeitemrootname$";
}
#endregion
}
}
看到這個線程http://stackoverflow.com/questions/4164928/how-to-suppress-code-analysis-on-generated-code,它有一些好主意,即使它們針對FxCop的人「XMLForDummies」說CodeGo.net,嘗試與代碼分析相同,它值得一看/嘗試。 –
因爲這已經在一個Designer.cs文件中,它已經包含了這些小東西。顯然,VS代碼分析甚至檢查了Designer文件,這對我來說有點荒謬;似乎他們應該是解決這些問題的人,而不是我!感謝您的鏈接,雖然;聽起來像我不是唯一得到一些不好的代碼分析結果的人。 – drharris
你應該能夠在全球壓制,全球壓制,文件,否? – BrainSlugs83