2011-02-15 109 views
7

SupressMessage的選項在VS 2010 Pro中不可用嗎?Visual Studio 2010 Pro - SuppressMessage

當我右鍵單擊警告列表中的警告時,沒有選項可以禁止。我也嘗試了錯誤,沒有選擇。然後我嘗試創建自己的GlobalSuppression.cs文件,但不知道該警告應歸入哪個類別。

現在我這樣做,它的工作原理,但我寧願使用GlobalSuppression文件

#pragma warning disable 0649,0169 
[Import(AllowRecomposition = false)] 
private IModuleManager _moduleManager; 

[Import(AllowRecomposition = false)] 
private IRegionManager _regionManager; 

[Import(AllowRecomposition = false)] 
private IRibbonService _menuService; 
#pragma warning restore 0649,0169 

這些是從輸出窗口,我要抑制警告:

warning CS0649: Field 'Shell._moduleManager' is never assigned to, and will always have its default value null 
warning CS0169: The field 'Shell._regionManager' is never used 
warning CS0649: Field 'Shell._menuService' is never assigned to, and will always have its default value null 

我想壓制的原因是我的解決方案使用Prism/MEF,因此這些變量是在運行時分配的。

回答

5

您看到的CSxxxx警告是C#編譯器警告,而不是FxCop /代碼分析警告。必須使用#pragma warning disable指令來抑制它們,而不是SuppressMessage屬性。

順便說一下,集成代碼分析只能在Premium或Ultimate中使用,而不能在Pro中使用。