VS2022代码分析配置选项非常混淆

发布于 2025-02-11 06:50:03 字数 817 浏览 0 评论 0原文

当我在VS2022中构建C#解决方案时,我会看到各种代码分析构建警告,例如:

IDE0090'new'表达式可以简化

我想将其中一些的严重性更改为“建议”,我认为这将继续显示编辑器Squiggle/Light Bulb,而不是构建警告。当我单击代码线旁边的灯泡时,出现了这组菜单:

有人可以解释四个'配置...'菜单选项之间的区别吗?即

  • “配置IDE 0090代码样式”
  • “配置IDE0090严重性”
  • “为所有'样式'分析仪配置配置严重性”
  • “为所有分析仪配置严重性

(第一个选项提供了“ true”&“ false”选择,而其他三个选项则提供“无”,而另外三个则提供“无”。 “,”静音”,...)

我不知道这是否相关,但是我的解决方案中的每个项目中都安装了“ stylecop.analyzer”软件包。

顺便说一句,在旁边看到的“更改预览窗格”图像的RH侧显示,它希望将新行添加到我的.editorConfig文件中,该文件属于解决方案的根文件夹中(我已经确认是根据行号和预览中看到的最后现有行)确认的是此文件)但是,每当我进行选择时,我会看到IDE 0090作为构建警告)

。到.editorconfig我自己通过记事本,然后警告消失了。

When I build my C# solution in VS2022 I see various code analysis build warnings, for example:

IDE0090 'new' expression can be simplified

I'd like to change the severity of some of these to "suggestion", which I assume will continue to display the editor squiggle/light bulb but not the build warning. When I click the light bulb next to the line of code, this set of menus appears:
enter image description here

Could someone explain the difference between the four 'Configure...' menu options please? I.E.

  • "Configure IDE0090 code style"
  • "Configure IDE0090 severity"
  • "Configure severity for all 'Style' analyzers"
  • "Configure severity for all analyzers

(The first option provides "true" & "false" choices, while the other three provide "None", "Silent", ...)

I don't know if this is relevant but I have the "StyleCop.Analyzers" package installed in each project in my solution.

As an aside, the "change preview pane" seen on the r.h. side of the image shows it wanting to add the new lines to my .editorconfig file, which lives in the solution's root folder (I've confirmed it is this file, based on the line numbers and last existing lines seen in the preview). However whenever I make a selection it never updates the file (and I continue to see IDE0090 appear as a build warning). Am I missing something? The file isn't read-only!

If I add the lines seen in the preview window to .editorconfig myself via Notepad then the warnings disappear.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文