为什么我不能使用最新的 .NET 5 和 NetAnalyzers 抑制 CA 违规?

问题描述

我将一个项目升级到 .NET 5,安装了最新的 Microsoft.CodeAnalysis.NetAnalyzers,并且我的 .editorconfig 文件中有这个:

dotnet_diagnostic.CA1506.severity = error

为什么我不能压制这个?

在错误列表中,右键单击错误时没有选项可以抑制。

所以我手动添加了这个属性到方法中:

[SuppressMessage("Microsoft.Maintainability","CA1506:AvoidExcessiveClassCoupling",Justification = "Existing class that matches every other project. This error is more important for business logic and not setup.")]
public IServiceProvider ConfigureServices(IServiceCollection services)

但每次编译时都会出错。我错过了什么?

编辑:我关闭了 VS 并重新打开它,现在错误消失了。当然这不可能是答案,不是吗?

编辑 2:我可以将鼠标悬停在不同的警告上并选择取消它,但不能取消 CA 1506。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...