question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support configuring dotnet-format with a configuration file

See original GitHub issue

As 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
sandyarmstrongcommented, Feb 5, 2020

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!

1reaction
jmarolfcommented, Feb 5, 2020

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 that dotnet 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found