Skip to content

Modify the -AsHashTable code to get the base object from the PSObject for the hashtable. - #7123

Merged
Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
BrucePay:brucepay_GroupObject
Jun 28, 2018
Merged

Modify the -AsHashTable code to get the base object from the PSObject for the hashtable.#7123
Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
BrucePay:brucepay_GroupObject

Conversation

@BrucePay

@BrucePay Bruce Payette (BrucePay) commented Jun 20, 2018

Copy link
Copy Markdown
Collaborator

PR Summary

Fix #6933.

Modified the Group-Object -AsHashTable code to get the base object from the PSObject before using the value to create a key in the hashtable.

PR Checklist

if (_grp.Values.Count == 1)
{
_table.Add(_grp.Values[0], _grp.Group);
_table.Add(PSObject.Base(_grp.Values[0]), _grp.Group);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest leaving a comment here since the change is rather subtle; otherwise, the change looks good to me.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the comment would be useful.

$result['Failed'].ErrorMessage.Count | Should -Be 5
$result['Failed'].ErrorMessage[0] | Should -Be 'SomeError'
$result['Successful'].ErrorMessage.Count | Should -Be 4
$result['Successful'].ErrorMessage[0] | Should -Be ''

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use more readable value instead of ''?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@powercode

Copy link
Copy Markdown
Collaborator

Bruce Payette (@BrucePay) Thanks for this! I've wanted to use it several times but always ended up being frustrated.

@iSazonov Ilya (iSazonov) changed the title Fix #6933 Modified the -AsHashTable code to get the base object from the PSObject for the hashtable. Modify the -AsHashTable code to get the base object from the PSObject for the hashtable. Jun 28, 2018
@iSazonov
Ilya (iSazonov) merged commit 1d54949 into PowerShell:master Jun 28, 2018
@iSazonov

Copy link
Copy Markdown
Collaborator

Bruce Payette (@BrucePay) I added "Fix #6933" to the PR description to automatically close the fixed issue after the PR is merged - no needs add this in PR header.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GroupObject -AsHashTable should "core" any PSObjects being used as keys

5 participants