8000 Add support empty NoteProperty in Group-Object by iSazonov · Pull Request #9109 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

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 @@ -113,12 +113,17 @@ public override bool Equals(Object inputObject)
public override int GetHashCode()
{
if (PropertyValue == null)
{
return 0;
}

object baseObject = PSObject.Base(PropertyValue);
IComparable baseObjectComparable = baseObject as IComparable;
if (baseObject == null)
{
return 0;
}

if (baseObjectComparable != null)
if (baseObject is IComparable)
{
return baseObject.GetHashCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ Describe "Group-Object" -Tags "CI" {
$result['Successful'].ErrorMessage.Count | Should -Be 4
$result['Successful'].ErrorMessage[0] | Should -Be ''
}

It "Should understand empty NoteProperty" {
$result = "dummy" | Select-Object -Property @{Name = 'X'; Expression = {}} | Group-Object X
$result.Count | Should -Be 1
$result[0].Name | Should -Be ""
$result[0].Group | Should -Be '@{X=}'
}
}

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