Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,12 @@ protected override void EndProcessing()
s_tracer.WriteLine(_groups.Count);
if (_groups.Count > 0)
{
if (AsHashTable)
if (AsHashTable.IsPresent)
{
Hashtable hashtable = CollectionsUtil.CreateCaseInsensitiveHashtable();
StringComparer comparer = CaseSensitive.IsPresent
? StringComparer.CurrentCulture
: StringComparer.CurrentCultureIgnoreCase;
var hashtable = new Hashtable(comparer);
try
{
if (AsString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-
$testCulture = "1049"
}

{$testObject | Group-Object -Culture $testCulture } | Should -Not -Throw
{ $testObject | Group-Object -Culture $testCulture } | Should -Not -Throw
}

It 'should not throw a key duplication error with -CaseSensitive -AsHashtable' {
$capitonyms = @(
[PSCustomObject]@{
Capitonym = 'Bill'
}
[PSCustomObject]@{
Capitonym = 'bill'
}
)

$Result = $capitonyms | Group-Object -Property Capitonym -AsHashTable -CaseSensitive
$Result | Should -BeOfType [HashTable]
$Result.Keys | Should -BeIn @( 'Bill', 'bill' )
}
}