From 67eacc9cc9a4c979b70c67e42edf905d5d9741d5 Mon Sep 17 00:00:00 2001 From: David Paulson Date: Fri, 29 May 2026 14:20:18 -0500 Subject: [PATCH] Fix CodeFormatter strict mode error with single file Use a typed List[object] instead of bare foreach assignment so .Count is always available under Set-StrictMode -Version Latest. Previously, a single FileInfo object lacks a .Count property in strict mode, causing a PropertyNotFoundException when CodeFormatter.ps1 processes exactly one changed file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .build/Invoke-CodeFormatterOnFiles.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.build/Invoke-CodeFormatterOnFiles.ps1 b/.build/Invoke-CodeFormatterOnFiles.ps1 index 95f2fc8a3c..ecdfead484 100644 --- a/.build/Invoke-CodeFormatterOnFiles.ps1 +++ b/.build/Invoke-CodeFormatterOnFiles.ps1 @@ -35,16 +35,17 @@ function Invoke-CodeFormatterOnFiles { $repoRoot = Get-Item "$PSScriptRoot\.." $errorCount = 0 + $filesToCheck = New-Object System.Collections.Generic.List[object] - $filesToCheck = foreach ($path in $FilePaths) { + foreach ($path in $FilePaths) { if (Test-Path -Path $path) { - Get-Item -Path $path + $filesToCheck.Add((Get-Item -Path $path)) } else { Write-Warning "File not found, skipping: $path" } } - if ($null -eq $filesToCheck -or $filesToCheck.Count -eq 0) { + if ($filesToCheck.Count -eq 0) { Write-Host "No valid files to check." return 0 }