1 回答
![?](http://img1.sycdn.imooc.com/545868b60001587202200220-100-100.jpg)
TA贡献1780条经验 获得超5个赞
要抑制 之外的警告GlobalSuppressions.cs,您可以:
使用注释(记得恢复超出范围的警告!)
#pragma warning disable IDE0052 // Remove unread private members
private readonly Object _obj;
#pragma warning restore IDE0052 // Remove unread private members
或SuppressMessage就地使用该属性
[SuppressMessage("Code Quality", "IDE0052:Remove unread private members", Justification = "<Pending>")]
private readonly Object _obj;
如果您想全局禁用它们,可以在解决方案的根目录下使用.editorconfig文件。
root = true
[*.{cs,vb}]
dotnet_diagnostic.IDE0052.severity = none
您还可以配置规则集文件,但现已弃用。
在您的 csproj 中:
<PropertyGroup>
<CodeAnalysisRuleSet>File.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
然后File.ruleset根据您的需要进行创建。看起来大致像
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Microsoft Managed Recommended Rules" Description="These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. It is recommended to include this rule set in any custom rule set you create for your projects." ToolsVersion="10.0">
<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
<Rule Id="CA1056" Action="None" />
</Rules>
</Rules>
</RuleSet>
- 1 回答
- 0 关注
- 80 浏览
添加回答
举报