如何使用 `dotnet format` 全局应用特定的 StyleCop 规则?

huangapple go评论55阅读模式
英文:

How to use `dotnet format` to apply specific StyleCop rule globally?

问题

我已经在我的使用C#编写的项目上安装了StyleCop.Analyzers。规则的严重性设置为suggestion

我应该如何使用dotnet format在整个项目上应用特定的规则?

我尝试执行dotnet format SolutionName.sln --diagnostics SA1122,以将所有的""替换为string.Empty。许多文件已经更新(文件时间戳已更改),但没有一个""被替换为预期的string.Empty

我应该如何使用dotnet format全局应用特定的格式规则,以便不必手动进行更改?

英文:

I have installed StyleCop.Analyzers on my project that is written using C#. The rules severity are set to suggestion.

How can I apply specific rules on the entire project using dotnet format?

I tried executing dotnet format SolutionName.sln --diagnostics SA1122 to convert all "" to string.Empty. Many files were updated (file timestamp changed), but none of the "" were replaced by string.Empty as expected.

How can I use dotnet format to apply specific format rule globally so I don't have to manually make the changes?

答案1

得分: 0

这可能是CLI命令中的问题。当与其他参数一起使用时,如 --severity info 时,它可以正常工作。

dotnet format SolutionName.sln --severity info --diagnostics SA1122
英文:

This maybe an issue in the CLI command. It works when used with other arguments like --severity info

dotnet format SolutionName.sln --severity info --diagnostics SA1122

huangapple
  • 本文由 发表于 2023年8月5日 03:11:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76838626.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定