Use the version of clang-format that comes with Visual Studio (#19821)

This pull request also (necessarily) reformats the code to match the
current version.

Visual Studio 2022 17.14 comes with Clang 19's `clang-format`.
This commit is contained in:
Dustin L. Howett
2026-02-02 13:45:11 -06:00
committed by GitHub
parent a449899789
commit 89d82638ab
22 changed files with 40 additions and 53 deletions

View File

@@ -416,28 +416,19 @@ function Invoke-CodeFormat() {
[switch]$IgnoreXaml
)
$clangFormatPath = & 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -find "**\x64\bin\clang-format.exe"
If ([String]::IsNullOrEmpty($clangFormatPath)) {
Write-Error "No Visual Studio-supplied version of clang-format could be found."
}
$root = Find-OpenConsoleRoot
& "$root\dep\nuget\nuget.exe" restore "$root\tools\packages.config"
$clangPackage = ([xml](Get-Content "$root\tools\packages.config")).packages.package | Where-Object id -like "clang-format*"
$clangFormatPath = "$root\packages\$($clangPackage.id).$($clangPackage.version)\tools\clang-format.exe"
Get-ChildItem -Recurse "$root\src" -Include *.cpp, *.hpp, *.h |
Where FullName -NotLike "*Generated Files*" |
Invoke-ClangFormat -ClangFormatPath $clangFormatPath
if ($IgnoreXaml) {
# do nothing
}
else {
if (-Not $IgnoreXaml) {
Invoke-XamlFormat
}
}
#.SYNOPSIS
# Download clang-format.exe required for code formatting
function Get-Format()
{
$root = Find-OpenConsoleRoot
& "$root\dep\nuget\nuget.exe" restore "$root\tools\packages.config"
}
Export-ModuleMember -Function Set-MsbuildDevEnvironment,Invoke-OpenConsoleTests,Invoke-OpenConsoleBuild,Start-OpenConsole,Debug-OpenConsole,Invoke-CodeFormat,Invoke-XamlFormat,Test-XamlFormat,Get-Format
Export-ModuleMember -Function Set-MsbuildDevEnvironment,Invoke-OpenConsoleTests,Invoke-OpenConsoleBuild,Start-OpenConsole,Debug-OpenConsole,Invoke-CodeFormat,Invoke-XamlFormat,Test-XamlFormat

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="clang-format.win-x86" version="15.0.7" targetFramework="native" />
</packages>