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 aslnfile or acsprojfile 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:\workspaceis a valid workspace if it has eitherC:\workspace\*.slnorC:\workspace\*.csproj. This mirrors the behavior fordotnet buildi.e. ifdotnet buildworks for a path thendotnet format --fix-styleshould 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 isinfoto 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-styleand--fix-analyzerscommands.
@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 aFixcommand 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--folderoption?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
-wsais that the would apply to both CodeStyle and Analyzer options. Whereas, with-wsa, I believe it applies to only the last specified.