Skip to content

Commit

Permalink
Restore dotnet-format local tool and add helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Aug 18, 2021
1 parent 86bba26 commit 45f01f2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Format.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\format.ps1""" %*"
6 changes: 6 additions & 0 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "6.0.240501",
"commands": [
"dotnet-format"
]
},
"powershell": {
"version": "7.0.0",
"commands": [
Expand Down
4 changes: 4 additions & 0 deletions eng/format.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

dotnet tool run dotnet-format $Args
5 changes: 5 additions & 0 deletions eng/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

dotnet tool run dotnet-format $@
2 changes: 1 addition & 1 deletion eng/test-build-correctness.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ try {
# Verify the state of our generated syntax files
Write-Host "Checking generated compiler files"
Exec-Block { & (Join-Path $PSScriptRoot "generate-compiler-code.ps1") -test -configuration:$configuration }
Exec-Console dotnet "format whitespace Compilers.sln --include-generated --include src/Compilers/CSharp/Portable/Generated/ --include src/Compilers/VisualBasic/Portable/Generated/ --include src/ExpressionEvaluator/VisualBasic/Source/ResultProvider/Generated/ --verify-no-changes"
Exec-Console dotnet "tool run dotnet-format . --include-generated --include src/Compilers/CSharp/Portable/Generated/ src/Compilers/VisualBasic/Portable/Generated/ src/ExpressionEvaluator/VisualBasic/Source/ResultProvider/Generated/ --check -f"
Write-Host ""

exit 0
Expand Down
16 changes: 16 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

source="${BASH_SOURCE[0]}"

# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"

# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done

scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
"$scriptroot/eng/format.sh" $@

0 comments on commit 45f01f2

Please sign in to comment.