Skip to content

Commit ac84c35

Browse files
authored
Fix regression in #20608. (#20745)
1 parent 272a5a9 commit ac84c35

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/Group-Object.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ private static string BuildName(List<ObjectCommandPropertyValue> propValues)
153153

154154
foreach (object item in propertyValueItems)
155155
{
156-
sb.AppendFormat(CultureInfo.CurrentCulture, $"{item}, ");
156+
sb.Append(CultureInfo.CurrentCulture, $"{item}, ");
157157
}
158158

159159
sb = sb.Length > length ? sb.Remove(sb.Length - 2, 2) : sb;
160160
sb.Append("}, ");
161161
}
162162
else
163163
{
164-
sb.AppendFormat(CultureInfo.CurrentCulture, $"{propValuePropertyValue}, ");
164+
sb.Append(CultureInfo.CurrentCulture, $"{propValuePropertyValue}, ");
165165
}
166166
}
167167
}

test/powershell/Modules/Microsoft.PowerShell.Utility/Group-Object.Tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ Describe "Group-Object" -Tags "CI" {
130130
$result[0].Name | Should -Be ""
131131
$result[0].Group | Should -Be '@{X=}'
132132
}
133+
134+
It "Should handle format-like strings with curly braces like normal strings" {
135+
$result = '{', '}', '{0}' | Group-Object
136+
$result.Count | Should -Be 3
137+
$result[0].Name | Should -BeExactly '{'
138+
$result[1].Name | Should -BeExactly '{0}'
139+
$result[2].Name | Should -BeExactly '}'
140+
}
133141
}
134142

135143
Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-Object, Compare-Object)" -Tags "CI" {

0 commit comments

Comments
 (0)