mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add support empty NoteProperty in Group-Object (#9109)
This commit is contained in:
@@ -113,12 +113,17 @@ namespace Microsoft.PowerShell.Commands
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user