Visual Studio 2010 Pro - 抑制消息
SupressMessage 选项在 VS 2010 Pro 中不可用吗?
当我右键单击警告列表中的警告时,没有选项可以抑制。我也尝试过,有错误,没有任何选择。然后,我尝试创建自己的 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 所以这些变量是在运行时分配的。
Is the option to SupressMessage not available in VS 2010 Pro?
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.
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
The reason why I want to suppress is that my solution uses Prism / MEF so those variables are assigned at runtime.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您看到的 CSxxxx 警告是 C# 编译器警告,而不是 FxCop/代码分析警告。必须使用
#pragma warning disable
指令来抑制它们,而不是 SuppressMessage 属性。顺便说一句,集成代码分析仅在 Premium 或 Ultimate 中可用,在 Pro 中不可用。
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.Incidentally, integrated Code Analysis is only availabe in Premium or Ultimate, not Pro.