Visual Studio 2010专业版-SuppressMessage [英] Visual Studio 2010 Pro - SuppressMessage

查看:170
本文介绍了Visual Studio 2010专业版-SuppressMessage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SupressMessage的选项在VS 2010 Pro中不可用吗?

Is the option to SupressMessage not available in VS 2010 Pro?

当我右键单击警告列表中的警告时,没有任何选项可以禁止显示.我也尝试了错误,没有选择.然后,我尝试创建自己的GlobalSuppression.cs文件,但不知道警告应归为哪一类.

When I right click on the warning in the warning list there is no option to suppress. I also tried it with errors and there was no option. I then tried to create my own GlobalSuppression.cs file but have no idea what category the warning should be classified under.

现在我正在执行此操作,该方法可以正常工作,但我希望使用GlobalSuppression文件

Right now I'm doing this, which works, but I would prefer to use a GlobalSuppression file

#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

这些是我想禁止的输出窗口警告:

These are the warnings from the output window that I want to suppress:

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,因此这些变量在运行时分配.

The reason why I want to suppress is that my solution uses Prism / MEF so those variables are assigned at runtime.

推荐答案

您看到的CSxxxx警告是C#编译器警告,而不是FxCop/代码分析警告.必须使用#pragma warning disable指令而不是SuppressMessage属性来抑制它们.

The CSxxxx warnings you are seeing are C# compiler warnings, not FxCop/Code Analysis warnings. They must be suppressed using #pragma warning disable directives, not SuppressMessage attributes.

偶然地,集成代码分析仅在Premium或Ultimate中可用,而在Pro中不可用.

Incidentally, integrated Code Analysis is only availabe in Premium or Ultimate, not Pro.

这篇关于Visual Studio 2010专业版-SuppressMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆