当构建一个新的异常时,抑制CA1303 fxcop警告。

问题描述 投票:0回答:1

当我在ASP.NET Core 3.1代码中抛出一个异常时,当它看到一个字符串文字作为一个参数时,fxcop就会警告我。new Exception(). 例如:

throw new InvalidOperationException("Ouch");

给我 CA1303: Do not pass literals as localized parameters

一般来说,我不会向终端用户显示异常消息,所以我不希望将它们本地化。是否有办法配置CA1303,使它忽略任何派生于 System.Exception?

EDIT:

经过更多的搜索,我发现了这个关于这个问题的对话。 After a bit more search, I've found this conversation about exactly this problem, https: /github comdotnetroslyn-analyzersissues2933。

https:/github.comdotnetroslyn-analyzersissues2933。

c# asp.net-core fxcop
1个回答
0
投票

如果你使用的是.editor config,你可以这样做。dotnet_code_quality.CA1303.use_naming_heuristic = true或者完全禁用CA1303

© www.soinside.com 2019 - 2024. All rights reserved.