Note: implicit in this doc is that we keep the name format
as the root command.
Command Format: dotnet format <workspace> --fix-whitespace
Fixes whitespace only. Just looks at files and folders
Alias: 'w'. Invoking dotnet format
without any arguments is equivalent to doing dotnet format --fix-whitespace
Arguments:
workspace
(Optional): a folder or file (must exist). If the path evaluated to either asln
file or acsproj
file we will attempt to laod it to determine the set of files to format. If the path evaluated to a folder or is not specified dotnet format uses the directory it was invoked from and just recurses through the files in that directory.
Command Format: dotnet format <workspace> --fix-style <severity>
Only fixes code style (aka code cleanup). Loads your solution or project.
Alias: 's'
Arguments:
-
workspace
(Optional): a path that contains a solution or project. soC:\workspace
is a valid workspace if it has eitherC:\workspace\*.sln
orC:\workspace\*.csproj
. This mirrors the behavior fordotnet build
i.e. ifdotnet build
works for a path thendotnet format --fix-style
should also work. If not specified dotnet format uses the directory it was invoked from. -
severity
(Optional): the severity of the code style options to fix. By default it isinfo
to ensure it fixes everything that is specified in your editorconfig file. Possible values areinfo
,warning
, anderror
.
Command Format: dotnet format <workspace> --fix-analyzers <severity>
Alias: 'a'
Arguments:
workspace
(Optional): evaluated identically to how it is for--fix-style
. If not specified dotnet format uses the directory it was invoked from.
Command Format: dotnet format <workspace> --fix-all <severity>
Alias: no alias for this command. passing -wsa
will do the same thing.
Arguments:
-
workspace
(Optional): evaluated identically to how it is for--fix-style
-
severity
(Optional): the severities passed into both the--fix-style
and--fix-analyzers
commands.
@jmarolf I like that you kept
--fix-
. Previously, we had talked about whether it was redundant. I think this will be a good bridge to it being incorporated into the CLI, especially if they introduce aFix
command for style and analyzers.Whitespace
Are you saying that if the
<workspace>
is folder that we do not search for a solution or project? Are you saying that there is no longer a--folder
option?I believe if the user has specified a solution or project it should be used as the workspace. There are repos with test assets that are not part of solutions today, which would be discovered and formatted when treating the path as folder of code files.
Fixing everything
The benefit this option has over
-wsa
is that the would apply to both CodeStyle and Analyzer options. Whereas, with-wsa
, I believe it applies to only the last specified.