gpt4 book ai didi

visual-studio-2010 - Visual Studio 2010 专业版 - SuppressMessage

转载 作者:行者123 更新时间:2023-12-04 08:16:06 27 4
gpt4 key购买 nike

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

最佳答案

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

顺便提一下,集成代码分析仅在 Premium 或 Ultimate 中可用,在 Pro 中不可用。

关于visual-studio-2010 - Visual Studio 2010 专业版 - SuppressMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5004832/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com