Visual Studio 2010 Pro - 抑制消息

发布于 2024-10-17 15:05:09 字数 908 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

刘备忘录 2024-10-24 15:05:09

您看到的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文