Support configuring dotnet-format with a configuration file
See original GitHub issueAs we add more options to the configuration it is increasingly tedious to type them all out at the command line.
- We should add support for reading in options from a “format.json” file.
- We should look for the configuration file in the current working directory.
- We should support multiple configurations stored as top-level properties. The configuration can be specified from the command line with a new
-c|--configuration {name}
option. A “default” option can be configured which will be applied whenever a configuration is not specified. - The option’s property name should match the long name for the option.
- Options that support multiple values provided as a comma separated string can be expressed as either a comma separated string or as an array of values.
- Options are optional in the configuration and will take their default value if missing or if
null
is specified for their value.
Example “format.json”:
{
"default": {
"folder": "./src",
"workspace": null,
"dry-run": false,
"check": false,
},
"all": {
"workspace": "format.sln",
"dry-run": false,
"check": false,
"files": null
},
"validate": {
"folder": "./src",
"workspace": null,
"dry-run": true,
"check": true,
"files": [ ]
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (9 by maintainers)
Top Results From Across the Web
dotnet format command - .NET CLI
The dotnet format command formats code to match EditorConfig settings for the current directory.
Read more >Using dotnet format Command to Format the C#/.NET Code
When we run the dotnet format command, the tool first searches for the .editorconfig file. Then it looks at the rules and our...
Read more >EditorConfig code formatting from the command line with . ...
You can use "dotnet format" as a global tool! It's one line to install, then it's available everywhere for all your .NET Core...
Read more >DotNet-Format vs. CSharpier: Which Auto-Formatting Tool ...
EditorConfig is an open-source file format. It provides a standard way to define coding styles for different file types in a project, such...
Read more >Dotnet Format and File Scoped Namespaces | Blog
It's used to format your codebase using rules specified in an .editorconfig file, and can ensure things like spacing, indentation, and whether ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My only addition here would be to make it a hidden file similar to
.gitconfig
and.editorconfig
. I’d suggest.dotnetformatconfig
or.formatconfig
.I really like the multiple configurations idea here. Cool stuff!
I am not opposed to this in theory. My main concern is that we create an alternative to
.editorconfig
. In most cases I would expect someone to update the.editorconfig
in their project to exclude/include files. I can see the rare case where I have some set of submodules that I need to configure, but my hope is that we first find a way to specify formatting options so thatdotnet format
, Visual Studio for Mac, VS Code, and Visual Studio can all do the same thing.All those concerns aside, I would tentatively accept a PR for this.