From f9f380db0a1970a28f427bf2f87fb330afdc801b Mon Sep 17 00:00:00 2001 From: peanut Date: Sat, 8 Aug 2026 13:36:48 +0200 Subject: [PATCH 1/2] Fix #2201: Include file path in SuggestedCorrections from AlignAssignmentStatement The CorrectionExtent constructor was being called with the rule message as the 6th argument (file), when it should be the 7th (description). --- Rules/AlignAssignmentStatement.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Rules/AlignAssignmentStatement.cs b/Rules/AlignAssignmentStatement.cs index 5b941924a..a727bc7d7 100644 --- a/Rules/AlignAssignmentStatement.cs +++ b/Rules/AlignAssignmentStatement.cs @@ -650,6 +650,7 @@ int targetColumn lhsExtent.EndColumnNumber, equalsExtent.StartColumnNumber, new string(' ', targetColumn - lhsExtent.EndColumnNumber), + lhsExtent.File, string.Format(CultureInfo.CurrentCulture, Strings.AlignAssignmentStatementError) ) }; From 368cfd3031535094baec4527983c2ceed898c000 Mon Sep 17 00:00:00 2001 From: peanut Date: Tue, 11 Aug 2026 22:12:46 +0200 Subject: [PATCH 2/2] Fix #2201: Add test for AlignAssignmentStatement to check SuggestedCorrection format --- Tests/Rules/AlignAssignmentStatement.tests.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/Rules/AlignAssignmentStatement.tests.ps1 b/Tests/Rules/AlignAssignmentStatement.tests.ps1 index 1262acdf8..a115af9d0 100644 --- a/Tests/Rules/AlignAssignmentStatement.tests.ps1 +++ b/Tests/Rules/AlignAssignmentStatement.tests.ps1 @@ -126,6 +126,21 @@ Configuration C1 { Context 'When Hashtable checking is enabled' { + It 'Should set correction file and description when analyzing a file' { + $path = Join-Path -Path $TestDrive -ChildPath 'unaligned.ps1' + Set-Content -LiteralPath $path -Value '@{"Key" = "Value"}' + + $settings = New-AlignAssignmentSettings -CheckHashtable $true + + $violations = Invoke-ScriptAnalyzer -Path $path -Settings $settings | + Get-NonParseDiagnostics + + $violations | Should -HaveCount 1 + $correction = $violations[0].SuggestedCorrections[0] + $correction.File | Should -Be ([IO.Path]::GetFullPath($path)) + $correction.Description | Should -Be 'Assignment statements are not aligned' + } + It 'Should not find violations in empty single-line hashtable' { $def = '@{}'