简体   繁体   English

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

[英]Can I run EditorConfig over C# Files From the Command Line?

Newer versions of Visual Studio Support EditorConfig within the IDE which is useful, however it would be best if I could run it from the command line (and therefore in automation). IDE 中较新版本的 Visual Studio 支持 EditorConfig,这很有用,但是如果我可以从命令行(因此在自动化中)运行它,那将是最好的。

Is there any stand alone tool that supports all of the EditorConfig Settings as the Visual Studio IDE does?有没有像 Visual Studio IDE 一样支持所有 EditorConfig 设置的独立工具? Microsoft Docs: .NET coding convention settings for EditorConfig Microsoft Docs:EditorConfig 的 .NET 编码约定设置

Here's what I have found so far:这是我迄今为止发现的:

Baring a stand alone tool is there any way to force Visual Studio into running the code cleanup "headless"?除了一个独立的工具,有没有办法强制 Visual Studio 运行代码清理“无头”? That might be my only solution.那可能是我唯一的解决方案。

I've been hunting for the same thing, just found a very new tool for this, dotnet-format , put out from the Roslyn team:我一直在寻找同样的东西,刚刚找到了一个非常新的工具, dotnet-format ,从 Roslyn 团队推出:

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

From their README:从他们的自述文件:

dotnet-format is a code formatter for dotnet that applies style preferences to a project or solution. dotnet-format是代码格式dotnet适用风格偏好的项目或解决方案。 Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used.将从.editorconfig文件中读取首选项(如果存在),否则将使用一组默认首选项。

Looks like the indented usage is something like:看起来缩进的用法是这样的:

$ dotnet format -w MyApplication.sln

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM