Skip to content

Commit 45f01f2

Browse files
committed
Restore dotnet-format local tool and add helper scripts
1 parent 86bba26 commit 45f01f2

6 files changed

Lines changed: 34 additions & 1 deletion

File tree

Format.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\format.ps1""" %*"

dotnet-tools.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"isRoot": true,
33
"tools": {
4+
"dotnet-format": {
5+
"version": "6.0.240501",
6+
"commands": [
7+
"dotnet-format"
8+
]
9+
},
410
"powershell": {
511
"version": "7.0.0",
612
"commands": [

eng/format.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
dotnet tool run dotnet-format $Args

eng/format.sh

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

eng/test-build-correctness.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ try {
6565
# Verify the state of our generated syntax files
6666
Write-Host "Checking generated compiler files"
6767
Exec-Block { & (Join-Path $PSScriptRoot "generate-compiler-code.ps1") -test -configuration:$configuration }
68-
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"
68+
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"
6969
Write-Host ""
7070

7171
exit 0

format.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
source="${BASH_SOURCE[0]}"
4+
5+
# resolve $SOURCE until the file is no longer a symlink
6+
while [[ -h $source ]]; do
7+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
8+
source="$(readlink "$source")"
9+
10+
# if $source was a relative symlink, we need to resolve it relative to the path where the
11+
# symlink file was located
12+
[[ $source != /* ]] && source="$scriptroot/$source"
13+
done
14+
15+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
16+
"$scriptroot/eng/format.sh" $@

0 commit comments

Comments
 (0)