8000 Group-Object - Use Case-Sensitive Hashtable for -CaseSensitive -AsHashtable by vexx32 · Pull Request #11030 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@vexx32
Copy link
Collaborator
@vexx32 vexx32 commented Nov 10, 2019

PR Summary

Prior to this change, Group-Object -AsHashtable -CaseSensitive would give a key duplication error when given entries that only differ by casing. This was due to always using a case-insensitive hashtable, despite the request for -CaseSensitive behaviour.

This change allows Group-Object -CaseSensitive -AsHashtable to create and return a case-sensitive hashtable to enable this use case.

PR Context

Resolves #10441

PR Checklist

- Group-Object -AsHashtable -CaseSensitive returns a case-sensitive hash
instead of erroring out when given keys differing only by case.

- Added tests
@vexx32 vexx32 added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 10, 2019
@vexx32 vexx32 requested a review from SteveL-MSFT November 10, 2019 04:55
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can simplify the code and this helps us to add Culture parameter later #9348:

var comparer = CaseSensitive.IsPresent ? StringComparer.CurrentCulture : StringComparer.CurrentCultureIgnoreCase;
hashtable = Hashtable(comparer);

Copy link
Collaborator Author
@vexx32 vexx32 Nov 10, 2019

Choose a reason for hiding this comment

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

Can do! I'm not sure if these methods use currentculture or ordinal though. I'll check :)

EDIT: It's CurrentCulture. 😄

Fixed in next commit. 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move style fixes in another PR. B 7440 elow too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

VS code's autoformat strikes again. It is in a separate commit at least, but if you'd prefer to do a whole separate PR I can manage. 🙂

@iSazonov iSazonov added this to the 7.0.0-preview.6 milestone Nov 10, 2019
@iSazonov iSazonov self-assigned this Nov 10, 2019
- Consolidate hashtable creation

- Better consistency of handling switches in conditionals
@vexx32 vexx32 force-pushed the GroupObjectCaseSensitiveHashtable branch from b94fffc to c307f2e Compare November 10, 2019 20:56
@vexx32
Copy link
Collaborator Author
vexx32 commented Nov 10, 2019

@iSazonov I think that should address all your concerns. I'll look at doing a style pass over the tests and possible the cmdlet after this PR is completed. 😊

@iSazonov
Copy link
Collaborator

@vexx32 I don't know should we document this in docs repo?

@vexx32
Copy link
Collaborator Author
vexx32 commented Nov 11, 2019

🤔 I suppose it should be documented since we're changing established behaviour. I'll open an issue. EDIT: Done!

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 11, 2019
…ect.Tests.ps1

Co-Authored-By: Steve Lee <slee@microsoft.com>
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 11, 2019
@iSazonov iSazonov added the AutoMerge informs the bot to automerge the PR label Nov 12, 2019
@ghost
Copy link
ghost commented Nov 12, 2019

Hello @iSazonov!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@vexx32
Copy link
Collaborator Author
vexx32 commented Nov 13, 2019

@SteveL-MSFT 🤔 do you know if the bot ignores non-required checks? Pretty sure it's waiting on the CodeFactor issue (which is just "complex method" on EndProcessing() here).

I'm happy to refactor it out into helper methods if you feel that's necessary. 🙂

@iSazonov iSazonov merged commit 57a4d4c into PowerShell:master Nov 13, 2019
@vexx32 vexx32 deleted the GroupObjectCaseSensitiveHashtable branch November 13, 2019 04:34
@ghost
Copy link
ghost commented Nov 21, 2019

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMerge informs the bot to automerge the PR CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return casesensitive hashtable with Group-Object

3 participants

0