Visual Studio 2010 Pro - SuppressMessage
问题描述:
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,因此这些变量是在运行时分配的。
答
您看到的CSxxxx警告是C#编译器警告,而不是FxCop /代码分析警告。必须使用#pragma warning disable
指令来抑制它们,而不是SuppressMessage属性。
顺便说一下,集成代码分析只能在Premium或Ultimate中使用,而不能在Pro中使用。