Skip to content

Commit

Permalink
Fix format.sh script and remove dotnet-format tool from dotnet-tools.…
Browse files Browse the repository at this point in the history
…json (#94839)

We're no longer using the separate dotnet-format tool since it is integrated into the dotnet SDK now.

With the move to the SDK the options changed a bit so we now need to use the `whitespace` format command so we can continue using the `--folder` option: dotnet/format#1385

To run not just whitespace but code style formatters as well we'd need a workspace context (i.e. pass the .csproj to dotnet format), but inferring that from just the changed file list is hard.
  • Loading branch information
akoeplinger authored Nov 16, 2023
1 parent 97c711f commit 883ffc4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
6 changes: 0 additions & 6 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
"commands": [
"slngen"
]
},
"dotnet-format": {
"version": "6.0.240501",
"commands": [
"dotnet-format"
]
}
}
}
2 changes: 1 addition & 1 deletion docs/coding-guidelines/code-formatting-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To help enable an easy workflow and reduce the number of formatting changes requ

### C#/VB

C# and VB code in the repository use the built-in Roslyn support for EditorConfig to enable auto-formatting in many IDEs. As a result, no additional tools are required to enable keeping your code formatted. If you want to use `dotnet format` to do formatting or are using the git pre-commit hook mentioned later in this document, you can run `./dotnet.cmd tool restore` or `./dotnet.sh tool restore` from the root of the repository to enable the `dotnet format` command.
C# and VB code in the repository use the built-in Roslyn support for EditorConfig to enable auto-formatting in many IDEs. As a result, no additional tools are required to enable keeping your code formatted. You can also use the `dotnet format` command from the dotnet SDK to do formatting or use the git pre-commit hook mentioned later in this document.

### C/C++

Expand Down
2 changes: 1 addition & 1 deletion eng/formatting/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

if [ -n "$MANAGED_FILES" ]; then
# Format all selected files
echo "$MANAGED_FILES" | cat | xargs | sed -e 's/ /,/g' | dotnet format --no-restore --include -
echo "$MANAGED_FILES" | cat | xargs | sed -e 's/ /,/g' | dotnet format whitespace --include - --folder

# Add back the modified files to staging
echo "$MANAGED_FILES" | xargs git add
Expand Down

0 comments on commit 883ffc4

Please sign in to comment.