Visual Studio不会抑制MVC1000警告
我们的一个项目存在很多问题,这些问题目前会导致数千个警告。这导致了一个新警告在开发过程中未被认可的问题。由于我们现在无法通过整个代码库解决所有警告,因此我们决定暂时禁用几种类型的警告。
我们添加了一个.editorConfig
文件,并尝试使用dotnet_diarostic
规则禁用某些警告:
[*.cs]
dotnet_diagnostic.CS0219.severity = none
dotnet_diagnostic.CS1998.severity = none
dotnet_diagnostic.CS4014.severity = none
dotnet_diagnostic.MVC1000.severity = none
这是针对前三个规则的预期工作的,但是使用Code 的警告> MVC1000
仍然出现在Visual Studio 2019(16.11.15)的错误列表中。这真的很奇怪,因为Visual Studio似乎在.editorConfig
文件中读取和理解该行,正如以下屏幕截图中可以看到的:
严重性也反映在.editorConfig
文件中。
有人知道为什么Visual Studio忽略了这条线,而不是其他三行?这一原因是否与视觉工作室定义的规则与分析仪定义的规则之间的差异联系在一起?有解决这个问题的解决方案吗?
更新:
我注意到某些cs0219
警告仍然出现在错误列表中,所有这些警告均来自.cshtml
文件,很有意义,因为现在只有.cs
文件在.editorConfig
文件中配置,这将导致所有MVC1000
显示的规则。现在,我也将文件更改为.cshtml
文件的appyly,现在警告不再显示在源文件中,但它们仍然显示在错误列表中:
[*.{cs,cshtml}]
dotnet_diagnostic.CS0219.severity = none
dotnet_diagnostic.CS1998.severity = none
dotnet_diagnostic.CS4014.severity = none
dotnet_diagnostic.MVC1000.severity = none
One of our projects has a lot of issues that cause over thousand warnings right now. This leads to the problem that new warnings go unrecognized during development. Since we cannot solve all warnings through the whole code base right now, we decided to temporarily disable several types of warnings.
We added a .editorconfig
file and tried to disable some warnings using dotnet_diagnostic
rules:
[*.cs]
dotnet_diagnostic.CS0219.severity = none
dotnet_diagnostic.CS1998.severity = none
dotnet_diagnostic.CS4014.severity = none
dotnet_diagnostic.MVC1000.severity = none
This works exactly as intended for the first three rules, however the warnings with the code MVC1000
still appear in the error list of Visual Studio 2019 (16.11.15). This is really strange, cause Visual Studio seems to read and understand the line in the .editorconfig
file, as it can be seen in the following screenshot:
Using the Visual Studio UI to change the severity also reflects in the .editorconfig
file.
Does anyone have an idea why Visual Studio ignores this line, but not the other three lines? Is the reason for this somehow linked to the difference between rules defined by Visual Studio and rules defined by an analyzer? Is there any solution to this problem?
Update:
I noticed that some of the CS0219
warnings still appear in the error list and that all of these warnings come from .cshtml
files, which makes sense, since right now only .cs
files are configured in the .editorconfig
file and this causes all MVC1000
rules to be shown. I now changed the file to appyly for .cshtml
files, too, and now the warnings are not shown in the source files anymore, but they still appear in the error list:
[*.{cs,cshtml}]
dotnet_diagnostic.CS0219.severity = none
dotnet_diagnostic.CS1998.severity = none
dotnet_diagnostic.CS4014.severity = none
dotnet_diagnostic.MVC1000.severity = none
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论