例如,在 .editorconfig
中,我可以使用以下两者要求字段为只读:
# IDE0044: Make field readonly
dotnet_diagnostic.IDE0044.severity = warning
和
dotnet_style_readonly_field = true:warning
两者都会显示在编辑器中,两者都会导致问题在运行dotnet format
时得到解决。这两个选项有什么区别?
最佳答案
The previous answer并不完全正确,因为它缺少 .editorconfig
外部的 EnforceCodeStyleInBuild = true
设置,但答案要复杂得多,请参阅 this文章。
在实践中,您必须考虑要执行什么规则、您拥有什么 IDE 以及这些 IDE 的版本,如果您有 CI/CD 等。
关于visual-studio - dotnet_diagnostics 和 dotnet_style_、csharp_ 等下的等效规则有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71314002/