我可以从命令行对 C# 文件运行 EditorConfig 吗?

aol*_*wka 5 c# code-cleanup editorconfig

IDE 中较新版本的 Visual Studio 支持 EditorConfig,这很有用,但是如果我可以从命令行(因此在自动化中)运行它,那将是最好的。

有没有像 Visual Studio IDE 一样支持所有 EditorConfig 设置的独立工具?Microsoft Docs:EditorConfig 的 .NET 编码约定设置

这是我迄今为止发现的:

除了一个独立的工具,有没有办法强制 Visual Studio 运行代码清理“无头”?那可能是我唯一的解决方案。

Rya*_*vis 5

我一直在寻找同样的东西,刚刚找到了一个非常新的工具,dotnet-format,从 Roslyn 团队推出:

https://github.com/dotnet/roslyn/tree/master/src/Tools/dotnet-format

从他们的自述文件:

dotnet-formatdotnet将样式首选项应用于项目或解决方案的代码格式化程序。将从.editorconfig文件中读取首选项(如果存在),否则将使用一组默认首选项。

看起来缩进的用法是这样的:

$ dotnet format -w MyApplication.sln
Run Code Online (Sandbox Code Playgroud)