Review currentculture (#11044)

Replace StringComparison.CurrentCulture with StringComparison.Ordinal where it is used without the need.
This commit is contained in:
Ilya 2019-11-22 08:37:42 +05:00 committed by GitHub
parent 35cfe4a99a
commit c17d5a7a27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 13 deletions

View file

@ -613,7 +613,7 @@ namespace Microsoft.PowerShell.Commands
foreach (string logName in eventLogSession.GetLogNames())
{
if (((!WildcardPattern.ContainsWildcardCharacters(logPattern))
&& string.Equals(logPattern, logName, StringComparison.CurrentCultureIgnoreCase))
&& string.Equals(logPattern, logName, StringComparison.OrdinalIgnoreCase))
||
(wildLogPattern.IsMatch(logName)))
{
@ -683,7 +683,7 @@ namespace Microsoft.PowerShell.Commands
foreach (string provName in eventLogSession.GetProviderNames())
{
if (((!WildcardPattern.ContainsWildcardCharacters(provPattern))
&& string.Equals(provPattern, provName, StringComparison.CurrentCultureIgnoreCase))
&& string.Equals(provPattern, provName, StringComparison.OrdinalIgnoreCase))
||
(wildProvPattern.IsMatch(provName)))
{
@ -2070,7 +2070,7 @@ namespace Microsoft.PowerShell.Commands
foreach (string actualLogName in eventLogSession.GetLogNames())
{
if (((!WildcardPattern.ContainsWildcardCharacters(logPattern))
&& (logPattern.Equals(actualLogName, StringComparison.CurrentCultureIgnoreCase)))
&& (logPattern.Equals(actualLogName, StringComparison.OrdinalIgnoreCase)))
||
(wildLogPattern.IsMatch(actualLogName)))
{
@ -2139,7 +2139,7 @@ namespace Microsoft.PowerShell.Commands
foreach (string provName in eventLogSession.GetProviderNames())
{
if (((!WildcardPattern.ContainsWildcardCharacters(provPattern))
&& (provPattern.Equals(provName, StringComparison.CurrentCultureIgnoreCase)))
&& (provPattern.Equals(provName, StringComparison.OrdinalIgnoreCase)))
||
(wildProvPattern.IsMatch(provName)))
{

View file

@ -231,7 +231,7 @@ namespace Microsoft.PowerShell.Commands
// Case sensitive duplicates should normally not occur since JsonConvert.DeserializeObject
// does not throw when encountering duplicates and just uses the last entry.
if (memberHashTracker.TryGetValue(entry.Key, out var maybePropertyName)
&& string.Compare(entry.Key, maybePropertyName, StringComparison.CurrentCulture) == 0)
&& string.Compare(entry.Key, maybePropertyName, StringComparison.Ordinal) == 0)
{
var errorMsg = string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.DuplicateKeysInJsonString, entry.Key);
error = new ErrorRecord(

View file

@ -1180,7 +1180,7 @@ namespace Microsoft.PowerShell.Commands
string relPath = _path;
if (!relPath.Equals(inputStream))
{
if (relPath.StartsWith(directory, StringComparison.CurrentCultureIgnoreCase))
if (relPath.StartsWith(directory, StringComparison.OrdinalIgnoreCase))
{
int offset = directory.Length;
if (offset < relPath.Length)

View file

@ -170,7 +170,7 @@ namespace System.Management.Automation
return;
}
if (string.Compare(result.Name, drive.Name, StringComparison.CurrentCultureIgnoreCase) == 0)
if (string.Compare(result.Name, drive.Name, StringComparison.OrdinalIgnoreCase) == 0)
{
// Set the drive in the current scope.
@ -1295,7 +1295,7 @@ namespace System.Management.Automation
// Make sure the provider didn't try to pull a fast one on us
// and substitute a different drive.
if (string.Compare(result.Name, drive.Name, StringComparison.CurrentCultureIgnoreCase) == 0)
if (string.Compare(result.Name, drive.Name, StringComparison.OrdinalIgnoreCase) == 0)
{
driveRemovable = true;
}

View file

@ -733,7 +733,7 @@ namespace System.Management.Automation
providerSpecificPath,
currentWorkingPath);
if (string.Compare(providerSpecificPath, currentWorkingPath, StringComparison.CurrentCultureIgnoreCase) == 0)
if (string.Compare(providerSpecificPath, currentWorkingPath, StringComparison.OrdinalIgnoreCase) == 0)
{
// The path is the current working directory so
// return true
@ -765,7 +765,7 @@ namespace System.Management.Automation
lockedDirectory,
providerSpecificPath);
if (string.Compare(lockedDirectory, providerSpecificPath, StringComparison.CurrentCultureIgnoreCase) == 0)
if (string.Compare(lockedDirectory, providerSpecificPath, StringComparison.OrdinalIgnoreCase) == 0)
{
// The path is a parent of the current working
// directory

View file

@ -1204,7 +1204,7 @@ namespace Microsoft.PowerShell.Commands
// and search backwards through the entries
for (int i = entries.Length - 1; i >= 0; i--)
{
if (entries[i].CommandLine.StartsWith(_commandLine, StringComparison.CurrentCulture))
if (entries[i].CommandLine.StartsWith(_commandLine, StringComparison.Ordinal))
{
entry = entries[i];
break;

View file

@ -5055,7 +5055,7 @@ namespace Microsoft.PowerShell.Commands
{
// Add the base path back on so that it can be used for
// processing
if (!result.StartsWith(basePath, StringComparison.CurrentCulture))
if (!result.StartsWith(basePath, StringComparison.Ordinal))
{
result = MakePath(basePath, result);
}
@ -5119,7 +5119,7 @@ namespace Microsoft.PowerShell.Commands
result = files.First();
#endif
if (result.StartsWith(basePath, StringComparison.CurrentCulture))
if (result.StartsWith(basePath, StringComparison.Ordinal))
{
result = result.Substring(basePath.Length);
}