Skip to content

Replace StringComparision.CurrentCulture with StringComparision.Ordinal - #8068

Merged
Ilya (iSazonov) merged 25 commits into
PowerShell:masterfrom
iSazonov:cleanup-culture
Oct 21, 2018
Merged

Ilya (iSazonov) merged 25 commits into
PowerShell:masterfrom
iSazonov:cleanup-culture

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Oct 18, 2018 •

Copy link
Copy Markdown
Collaborator

PR Summary

Related #8064

Replace StringComparision.CurrentCulture with StringComparision.Ordinal.

Best Practices for Using Strings in .NET

Not all code base is fixed. There are not obvious cases.

PR Checklist


This change is Reviewable

@iSazonov Ilya (iSazonov) added the Issue-Code Cleanup the issue is for cleaning up the code with no impact on functionality label Oct 18, 2018
@iSazonov Ilya (iSazonov) self-assigned this Oct 18, 2018
@TravisEz13

Copy link
Copy Markdown
Member

src/Microsoft.WSMan.Management/WSManConnections.cs, line 143 at r1 (raw file):

            {
                computername = value;
                if ((string.IsNullOrEmpty(computername)) || (computername.Equals(".", StringComparison.OrdinalIgnoreCase)))

I've seen this in many places, perhaps we should have a central place for this code?

@TravisEz13 Travis Plunk (TravisEz13) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed 24 of 24 files at r1.
Reviewable status: :shipit: complete! all files reviewed

@TravisEz13

Copy link
Copy Markdown
Member

We probably should fix this one as well:

Hashtable hashtable = new Hashtable(StringComparer.CurrentCultureIgnoreCase);

@TravisEz13

Copy link
Copy Markdown
Member

Thinking about it further with James Truher (@JamesWTruher) , Hashtable could be culture sensitive in some cases. This should be a different PR and probably be behind an experimental flag.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Hashtable could be culture sensitive in some cases.

Travis Plunk (@TravisEz13) In the PR I fixed only obvious cases. There are still about 30 unclear cases left. It would be great if MSFT team reviewed them.

I've seen this in many places, perhaps we should have a central place for this code?

If we should please open a tracking issue and I'll fix this later.

@iSazonov
Ilya (iSazonov) merged commit 0a4f33a into PowerShell:master Oct 21, 2018
@iSazonov
Ilya (iSazonov) deleted the cleanup-culture branch October 21, 2018 11:11
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

Issue-Code Cleanup the issue is for cleaning up the code with no impact on functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants