GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add -Name, -NoUserOverrides and -ListAvailable parameters to Get-Culture cmdlet by iSazonov · Pull Request #7702 · PowerShell/PowerShell

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Sep 4, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

PR Summary

Address #3832

Add new parameters in Get-Culture cmdlet:

  • -Name - to allow retrieving a specific culture
  • -NoUserOverrides - ignore user changes for current culture
  • -ListAvalable - to allow retrieving all cultures supported on the platform

Documentation

Please see https://github.com/dotnet/corefx/issues/6374#issuecomment-418827420 and following comments.
In short .Net Core accept all culture names in BCP-47 format and then delegate to OS so result depends on OS behavior and differ on different OS-s.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov Ilya (iSazonov) added Review - Committee The PR/Issue needs a review from the PowerShell Committee Documentation Needed in this repo Documentation is needed in this repo labels Sep 4, 2018
@iSazonov
Ilya (iSazonov) requested review from James Truher (JamesWTruher), Paul Higinbotham (PaulHigin) and Dan Travison (dantraMSFT) as code owners September 4, 2018 15:00
@iSazonov
Ilya (iSazonov) requested a review from Steve Lee (SteveL-MSFT) September 4, 2018 15:01
@iSazonov
Ilya (iSazonov) force-pushed the get-culture branch from d7afc9a to 64e1f70 Compare September 4, 2018 15:07
@iSazonov

Ilya (iSazonov) commented Sep 4, 2018

Copy link
Copy Markdown
Collaborator Author

/cc Michael Klement (@mklement0)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mklement0
Michael Klement (mklement0) reviewed Sep 4, 2018
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated

@mklement0 Michael Klement (mklement0) Sep 4, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

As an aside: I don't think it's worth reflecting that the property representing the parameter is read/write (that can easily be gleaned from the code) - just stating the purpose of the parameter should be sufficient.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Sep 4, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The comment should start with "Gets and sets" to fix CodeFactor issue.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mklement0 Michael Klement (mklement0) Sep 4, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I see, but in this context such comments are more confusing than helpful. I know nothing about CodeFactor: does this particular rule a default rule, or one that was specifically turned on for this repo?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Sep 5, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Native language is very flexible - I reworded the comment.

CodeFactor is a service. It uses StypeCop static analyzer too. Yes, we can to turn in/out rules. Currently we have some PRs to turn StypeCop and editors settings. Plan is to complete the work after 6.1 GA.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mklement0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
mklement0
Michael Klement (mklement0) suggested changes Sep 4, 2018
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

SteveL-MSFT
Steve Lee (SteveL-MSFT) requested changes Sep 4, 2018
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated

@SteveL-MSFT Steve Lee (SteveL-MSFT) Sep 4, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is there a reason to do this in EndProcessing vs ProcessRecord? Typically, EndProcessing is used for cleanup after the pipeline has completed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mklement0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@iSazonov Ilya (iSazonov) Sep 5, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Initially we do not support pipelines and using EndProcessing() was ok. Currently the cmdlet was enhanced to support pipelines and the code was moved to ProcessRecord().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov

Ilya (iSazonov) commented Sep 5, 2018

Copy link
Copy Markdown
Collaborator Author

I discovered that

Get-Culture "abc"

return CultureInfo object - there is no exception internally. Seems it is "by design" and based on OS behavior. See https://github.com/dotnet/corefx/issues/1669. Perhaps we should add this in documentation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mklement0

Michael Klement (mklement0) commented Sep 5, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Ilya (@iSazonov): That is unfortunate; the problem has since been fixed on Windows, but macOS and Linux are still affected. - see below.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Sep 5, 2018

Copy link
Copy Markdown
Collaborator Author

I see. I'll skip the test on Linux and MacOs. Should I add a comment that it is a bug in .Net Core? Is there a tracking issue?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mklement0

Michael Klement (mklement0) commented Sep 5, 2018

Copy link
Copy Markdown
Contributor

I would personally consider it a bug, but I've only read the CoreFx issue that you linked to; from there I came across https://github.com/dotnet/corefx/issues/6374#issuecomment-245706306, which promises a fix on Linux, but hat seemingly never happened.

May be worth opening a new issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Sep 5, 2018

Copy link
Copy Markdown
Collaborator Author

Michael Klement (@mklement0) Thanks! I added a comment there.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dantraMSFT
Dan Travison (dantraMSFT) suggested changes Sep 5, 2018
View reviewed changes
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Culture.Tests.ps1 Outdated

@dantraMSFT Dan Travison (dantraMSFT) Sep 5, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suggest adding the issue link as a comment for -Skip

https://github.com/dotnet/corefx/issues/6374

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Sep 6, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I updated the test - now it throw on Unix-es too. Link to useful comment added too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated

@dantraMSFT Dan Travison (dantraMSFT) Sep 5, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Shouldn't this be ValidateNotNullOrEmpty?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Sep 6, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

For empty string name InvariantCulture is returned.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@dantraMSFT Dan Travison (dantraMSFT) Sep 6, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ilya (@iSazonov) - I think that behavior's too subtle.

Additionally, the ProcessRecord doesn't match the class comment (Return's the thread's current culture). In short, reviewing the code appears to not support getting the current culture.

NOTE: Line 40 that compares Name to null 'looks' like dead code since name must be non-null for the Name parameter set. Having an explicit or fall through 'default' case statement will make this clearer.

I suggest the following:

1: Retain the original behavior explicitly
Set the DefaultParameterSetName to 'default' and return the thread's current culture.

2: Name parameter set
Either clearly document that an empty string returns InvariantCulture or don't allow empty strings and require explicit names.

3: ListAvailable
As implemented.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mklement0 Michael Klement (mklement0) Sep 6, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I too think that "" is obscure and suggest requiring explicit use of Invariant-Culture, i.e.:

Get-Culture Invariant-Culture

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Sep 7, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

1 - Fixed.
2- Let's consider the scenario - script asks user to input a culture, user press Enter to choose "Default". Without user typing the script get empty string as "default". I guess CoreFX consider InvariantCulture as default if culture is unknown or not selected. We use InvariantCulture widely in PowerShell code too. So allowing empty string in Get-Culture looks good.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mklement0 Michael Klement (mklement0) Sep 7, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Re 2: Curiously, the empty string is not just a placeholder that signals the intent to retrieve the invariant culture when you call .GetCultureInfo(), it is the actual value of the .Name property of the culture-info object returned - so I guess it makes sense to surface that.(Unlike what I thought earlier, "Invariant-Culture" doesn't actually work; on Unix it implicitly creates an ad-hoc culture, on Windows it breaks.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Perhaps add a comment about this in the code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 15, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Added.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Sep 5, 2018

Copy link
Copy Markdown
Member

@PowerShell/powershell-committee reviewed this and continue to be consistent in our thinking that for literals, a non-terminating error should be returned, and for filtering/wildcards, it should return nothing if not found. Should also consider adding a Test-Culture cmdlet.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT Steve Lee (SteveL-MSFT) added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Sep 5, 2018
@mklement0

Michael Klement (mklement0) commented Sep 6, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Sorry - my earlier statement was incorrect:

The - questionable - logic of the CultureInfo.GetCultureInfo() method is the same across all platforms in the abstract:

  • A culture name that is formally correct returns a culture-info object, even if there is no such predefined culture - I'm unclear on when and why that is useful.

  • A formally incorrect culture name triggers a System.Globalization.CultureNotFoundException, which makes sense.

What constitutes a formally correct culture name is platform-specific, however:

  • Windows: a well-formed BCP-47 tag, such as fr, ru-RU, or zz-AA-oooooooo
  • Unix (macOS and Linux): a name composed of up to 11 characters, whatever they are, and seemingly even more if there's a . present (I'm unclear on the exact rules); e.g., 01;2.45"78&$ (sic); according to the linked CoreFx issue, the "ICU library" is used behind the scenes on these platforms.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mklement0

Michael Klement (mklement0) commented Sep 6, 2018

Copy link
Copy Markdown
Contributor

I guess we can work around this by validating names against CultureInfo.GetCultures(CultureTypes.AllCultures) while we're waiting for a CoreFX fix - which may or may not come.

Steve Lee (@SteveL-MSFT): Currently, the PR has no wildcard support for -Name - should we add it? Might be handy, but adds implementation complexity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Sep 6, 2018

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT)

Should also consider adding a Test-Culture cmdlet.

We have #7562. I suggest to explicitly track all approved Test-* cmdlets there.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT Steve Lee (SteveL-MSFT) mentioned this pull request Sep 6, 2018
There should be more Test-Command and Test-Module cmdlets #7562
Closed
1 task
@iSazonov

Ilya (iSazonov) commented Sep 6, 2018

Copy link
Copy Markdown
Collaborator Author

I guess we can work around this

Michael Klement (@mklement0) I think it is ok to follow .Net Core behavior "as is" - if they really think it's right, then we can hardly do better.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mklement0

Michael Klement (mklement0) commented Sep 6, 2018

Copy link
Copy Markdown
Contributor

Ilya (@iSazonov): Since we're not just providing access to the underlying CoreFx functionality, but packaging it in a PowerShell-appropriate way, I don't think we're obligated to surface the functionality as-is.

I have yet to hear a good reason for the CoreFx behavior (there may be one, but I haven't heard it), and users who really want to implicitly create cultures such as zz-AA and 01;2.45"78&$ can use the CoreFx types directly.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Sep 6, 2018

Copy link
Copy Markdown
Collaborator Author

Michael Klement (@mklement0) With -ListAvailable we get good UX. We could add a filter for -Name (based on a completer) but it can be expensive and it seems we do not fully understand the behavior of .Net Core in order to overlap it. I think we shouldn't delay the PR, we can postpone this and fix later if needed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dantraMSFT
Dan Travison (dantraMSFT) suggested changes Sep 6, 2018
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated

@dantraMSFT Dan Travison (dantraMSFT) Sep 6, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ilya (@iSazonov) - I think that behavior's too subtle.

Additionally, the ProcessRecord doesn't match the class comment (Return's the thread's current culture). In short, reviewing the code appears to not support getting the current culture.

NOTE: Line 40 that compares Name to null 'looks' like dead code since name must be non-null for the Name parameter set. Having an explicit or fall through 'default' case statement will make this clearer.

I suggest the following:

1: Retain the original behavior explicitly
Set the DefaultParameterSetName to 'default' and return the thread's current culture.

2: Name parameter set
Either clearly document that an empty string returns InvariantCulture or don't allow empty strings and require explicit names.

3: ListAvailable
As implemented.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mklement0

Michael Klement (mklement0) commented Sep 6, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Ilya (@iSazonov): Postponing wildcard support sounds good to me, but I do think we should get clarity on whether we truly want to support calls such as Get-Culture '01;2.45"78&$', because if we do so now, we have a breaking change on our hands if we want to change it later.

I see only down-sides to surfacing the baffling CoreFx functionality as-is.

Conversely, if we restrict allowed names to the ones reported by -ListAvailable now, it is less problematic to loosen that restriction later, if it turns out that that is really necessary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Sep 7, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

whether we truly want to support calls such as Get-Culture '01;2.45"78&$', because if we do so now, we have a breaking change on our hands if we want to change it later.

I don't know whether we truly want. The breaking change will be in grace arae - I'd expect users will use right culture names. On the other hand, it is not clear what the filter should be. from the CoreFX discussion we know that there may be some special logic. There can be a situation similar we see with encodings - we get a short list but really supported encodings there is more.
I suggest document the feature and wait feedback.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov
Ilya (iSazonov) force-pushed the get-culture branch from 4abc5df to 173849d Compare October 12, 2018 08:59
@iSazonov

Ilya (iSazonov) commented Oct 12, 2018

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) Michael Klement (@mklement0) The PR is ready for final review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SteveL-MSFT
Steve Lee (SteveL-MSFT) requested changes Oct 12, 2018
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Perhaps add a comment about this in the code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Agree, based on @PowerShell/powershell-committee discussion we should only return cultures from the AllCultures list. Creation is out of scope of this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Culture.Tests.ps1 Outdated

It "Should have `$PSCulture variable be equivalent to (Get-Culture).Name" {

(Get-Culture).Name | Should -Be $PsCulture

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Based on the test description, it would seem that this should be:

$PSCulture | Should -BeExactly (Get-Culture).Name

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 15, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think the order is right because the file is for Get-Culture tests and we should correct the description.
But I'd expect that we check $Host.CurrentCulture instead of $PsCulture.
On other side, we haven't tests for special variables at all.

What do you think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 15, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm fine changing the test description to match the test and adding separate test for $PSCulture

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 16, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Culture.Tests.ps1

It "Should return specified cultures with '-Name' parameter" {

$ciArray = Get-Culture "", "ru-RU"

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Seems like we should have a specific test case to handle invariant culture making it clear what is being validated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 15, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Added the check and comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated
{
if (NoUserOverrides && string.Equals(cultureName, Host.CurrentCulture.Name, StringComparison.CurrentCultureIgnoreCase))
{
ci = new CultureInfo(cultureName, false);

@SteveL-MSFT Steve Lee (SteveL-MSFT) Oct 12, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please use named params here

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 15, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mklement0
Michael Klement (mklement0) suggested changes Oct 12, 2018
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated
case CurrentCultureParameterSet:
if (NoUserOverrides)
{
ci = CultureInfo.GetCultureInfo(Host.CurrentCulture.LCID);

@mklement0 Michael Klement (mklement0) Oct 12, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please use .Name instead of .LCID, and we should probably do the same for all tests.

"LCIDs are being deprecated, and implementers are strongly encouraged to use locale names instead. LCIDs can be used for backward compatibility, but as noted in section 2.2.1, there is no guarantee of LCID uniqueness when used with valid locale names not otherwise associated with an LCID. " - from "[MS-LCID]: Windows Language Code Identifier (LCID) Reference" - https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-LCID/[MS-LCID].pdf

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 15, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think the change is not related to and not critical for the PR. We can postpone the change until CoreFX obsolete the API.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mklement0 Michael Klement (mklement0) Oct 15, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

[cultureinfo]::getcultures('allcultures') | group-object lcid | ? count -gt 1 will tell you that hundreds of predefined cultures share the same LCID, so this fix is an absolute must.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 15, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetCultureCommand.cs Outdated
{
foreach (var cultureName in Name)
{
if (NoUserOverrides && string.Equals(cultureName, Host.CurrentCulture.Name, StringComparison.CurrentCultureIgnoreCase))

@mklement0 Michael Klement (mklement0) Oct 12, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This should be !NoUserOverrides and the 2nd CultureInfo constructor argument below should be true (or omitted), but you could just use Host.CurrentCulture, which also reflects the overrides.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Oct 15, 2018

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ilya (iSazonov) added 3 commits October 15, 2018 12:20
@iSazonov
Address feedbacks
14b8e7b
@iSazonov
Skip test on Unix
7bcee51
@iSazonov
Replace LCID with name
d00a899
@joeyaiello Joey Aiello (joeyaiello) mentioned this pull request Oct 15, 2018
Docs needed for 'Add -Name, -ListAvailable, and -NoUserOverrides parameters to Get-Culture cmdlet' MicrosoftDocs/PowerShell-Docs#3025
Closed
@joeyaiello Joey Aiello (joeyaiello) removed Documentation Needed in this repo Documentation is needed in this repo labels Oct 15, 2018
@iSazonov
Change tests description and add new test
c12d1a1
@iSazonov

Ilya (iSazonov) commented Oct 16, 2018

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) Please point me comments if I missed something.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SteveL-MSFT
Steve Lee (SteveL-MSFT) approved these changes Oct 18, 2018
View reviewed changes

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov

Ilya (iSazonov) commented Oct 18, 2018

Copy link
Copy Markdown
Collaborator Author

Michael Klement (@mklement0) Please update your review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) closed this Oct 18, 2018
@iSazonov Ilya (iSazonov) reopened this Oct 18, 2018
@iSazonov

Ilya (iSazonov) commented Oct 18, 2018

Copy link
Copy Markdown
Collaborator Author

Reopen to restart all CIs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mklement0
Michael Klement (mklement0) approved these changes Oct 18, 2018
View reviewed changes
@iSazonov
Fix test
a54d534
@iSazonov Ilya (iSazonov) mentioned this pull request Oct 18, 2018
New parameters in Get-Culture cmdlet MicrosoftDocs/PowerShell-Docs#3138
Closed
2 of 8 tasks
@iSazonov Ilya (iSazonov) changed the title Add -Name and -ListAvailable parameters to Get-Culture cmdlet Add -Name, -NoUserOverrides and -ListAvailable parameters to Get-Culture cmdlet Oct 18, 2018
@iSazonov
Ilya (iSazonov) merged commit f1e2136 into PowerShell:master Oct 18, 2018
@iSazonov
Ilya (iSazonov) deleted the get-culture branch October 18, 2018 12:34
@iSazonov

Ilya (iSazonov) commented Oct 18, 2018

Copy link
Copy Markdown
Collaborator Author

Michael Klement (@mklement0) Many thanks for great help!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mklement0

Michael Klement (mklement0) commented Oct 18, 2018

Copy link
Copy Markdown
Contributor

My pleasure, Ilya (@iSazonov), thanks for implementing it all.

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mklement0 Michael Klement (mklement0) mentioned this pull request Jan 31, 2020
API proposal: Extend CultureInfo.GetCultureInfo and new CultureInfo to optionally accept predefined cultures only dotnet/runtime#27352
Closed
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@iSazonov
Add -Name, -NoUserOverrides and -ListAvailable parameters to Get-Cult…
f3af0ff
…ure cmdlet (PowerShell#7702)

Add new parameters in Get-Culture cmdlet:
-Name - to allow retrieving a specific culture
-NoUserOverrides - ignore user changes for current culture
-ListAvalable - to allow retrieving all cultures supported on the platform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@SteveL-MSFT Steve Lee (SteveL-MSFT) SteveL-MSFT approved these changes
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
@PaulHigin Paul Higinbotham (PaulHigin) Awaiting requested review from PaulHigin
+2 more reviewers
@dantraMSFT Dan Travison (dantraMSFT) dantraMSFT requested changes
@mklement0 Michael Klement (mklement0) mklement0 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@iSazonov @mklement0 @SteveL-MSFT @vexx32 @dantraMSFT @joeyaiello
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.