diff --git a/src/System.Management.Automation/engine/SessionStateLocationAPIs.cs b/src/System.Management.Automation/engine/SessionStateLocationAPIs.cs index 7237134f16..e9fa884603 100644 --- a/src/System.Management.Automation/engine/SessionStateLocationAPIs.cs +++ b/src/System.Management.Automation/engine/SessionStateLocationAPIs.cs @@ -545,7 +545,7 @@ namespace System.Management.Automation // Remove the root slash since it is implied that the // current working directory is relative to the root. if (!LocationGlobber.IsProviderDirectPath(path) && - path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal) && + path.StartsWith(StringLiterals.DefaultPathSeparator) && !pathIsProviderQualifiedPath) { path = path.Substring(1); diff --git a/src/System.Management.Automation/engine/SessionStateStrings.cs b/src/System.Management.Automation/engine/SessionStateStrings.cs index b79cbafb5a..6c44dfd92b 100644 --- a/src/System.Management.Automation/engine/SessionStateStrings.cs +++ b/src/System.Management.Automation/engine/SessionStateStrings.cs @@ -170,7 +170,7 @@ namespace System.Management.Automation /// /// The escape character used in the language. /// - internal const string EscapeCharacter = "`"; + internal const char EscapeCharacter = '`'; /// /// The default cmdlet adapter for cmdletization / cdxml modules diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index b743048389..903c752ea2 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -1425,8 +1425,8 @@ namespace Microsoft.PowerShell.Commands // Don't handle full paths, paths that the user is already trying to // filter, or paths they are trying to escape. if ((!String.IsNullOrEmpty(filter)) || - (path.Contains(StringLiterals.DefaultPathSeparatorString)) || - (path.Contains(StringLiterals.AlternatePathSeparatorString)) || + (path.Contains(StringLiterals.DefaultPathSeparator, StringComparison.Ordinal)) || + (path.Contains(StringLiterals.AlternatePathSeparator, StringComparison.Ordinal)) || (path.Contains(StringLiterals.EscapeCharacter))) { return false; @@ -4814,13 +4814,13 @@ namespace Microsoft.PowerShell.Commands try { string originalPathComparison = path; - if (!originalPathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)) + if (!originalPathComparison.EndsWith(StringLiterals.DefaultPathSeparator)) { originalPathComparison += StringLiterals.DefaultPathSeparator; } string basePathComparison = basePath; - if (!basePathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)) + if (!basePathComparison.EndsWith(StringLiterals.DefaultPathSeparator)) { basePathComparison += StringLiterals.DefaultPathSeparator; } @@ -5018,7 +5018,7 @@ namespace Microsoft.PowerShell.Commands // See if the base and the path are already the same. We resolve this to // ..\Leaf, since resolving "." to "." doesn't offer much information. if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase) && - (!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))) + (!originalPath.EndsWith(StringLiterals.DefaultPathSeparator))) { string childName = GetChildName(path); result = MakePath("..", childName); @@ -5065,7 +5065,7 @@ namespace Microsoft.PowerShell.Commands if (!String.IsNullOrEmpty(commonBase)) { if (String.Equals(path, commonBase, StringComparison.OrdinalIgnoreCase) && - (!path.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))) + (!path.EndsWith(StringLiterals.DefaultPathSeparator))) { string childName = GetChildName(path); result = MakePath("..", result); diff --git a/src/System.Management.Automation/namespaces/LocationGlobber.cs b/src/System.Management.Automation/namespaces/LocationGlobber.cs index 0ed27c7324..22ae25e8b8 100644 --- a/src/System.Management.Automation/namespaces/LocationGlobber.cs +++ b/src/System.Management.Automation/namespaces/LocationGlobber.cs @@ -1436,8 +1436,8 @@ namespace System.Management.Automation internal static bool IsSingleFileSystemAbsolutePath(string path) { #if UNIX - return path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal) - || path.StartsWith(StringLiterals.AlternatePathSeparatorString, StringComparison.Ordinal); + return path.StartsWith(StringLiterals.DefaultPathSeparator) + || path.StartsWith(StringLiterals.AlternatePathSeparator); #else return false; #endif @@ -2898,7 +2898,7 @@ namespace System.Management.Automation } else { - if (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + if (path.StartsWith(StringLiterals.DefaultPathSeparator)) { formatString = "{0}:{1}"; } @@ -3088,8 +3088,8 @@ namespace System.Management.Automation // Check if the path begins with "\" or "/" (UNC Path or Path in Unix). // Ignore if the path resolves to a drive path, this will happen when path is equal to "\" or "/". // Drive path still need formatting, so treat them as relative. - if (path.Length > 1 && (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal) || - path.StartsWith(StringLiterals.AlternatePathSeparatorString, StringComparison.Ordinal))) + if (path.Length > 1 && (path.StartsWith(StringLiterals.DefaultPathSeparator) || + path.StartsWith(StringLiterals.AlternatePathSeparator))) { treatAsRelative = false; } @@ -3109,7 +3109,7 @@ namespace System.Management.Automation if (drive.VolumeSeparatedByColon) { formatString = "{0}:" + StringLiterals.DefaultPathSeparator + "{1}"; - if (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + if (path.StartsWith(StringLiterals.DefaultPathSeparator)) { formatString = "{0}:{1}"; } diff --git a/src/System.Management.Automation/namespaces/NavigationProviderBase.cs b/src/System.Management.Automation/namespaces/NavigationProviderBase.cs index c401b1e317..4792027930 100644 --- a/src/System.Management.Automation/namespaces/NavigationProviderBase.cs +++ b/src/System.Management.Automation/namespaces/NavigationProviderBase.cs @@ -345,7 +345,7 @@ namespace System.Management.Automation.Provider // Append the default path separator - if (parent.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + if (parent.EndsWith(StringLiterals.DefaultPathSeparator)) { result = parent; } @@ -377,9 +377,9 @@ namespace System.Management.Automation.Provider StringBuilder builder = new StringBuilder(parent, parent.Length + child.Length + 1); - if (parent.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + if (parent.EndsWith(StringLiterals.DefaultPathSeparator)) { - if (child.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + if (child.StartsWith(StringLiterals.DefaultPathSeparator)) { builder.Append(child, 1, child.Length - 1); } @@ -390,7 +390,7 @@ namespace System.Management.Automation.Provider } else { - if (child.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)) + if (child.StartsWith(StringLiterals.DefaultPathSeparator)) { if (parent.Length == 0) { @@ -598,7 +598,7 @@ namespace System.Management.Automation.Provider string originalPath = path; Stack tokenizedPathStack = null; - if (path.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)) + if (path.EndsWith(StringLiterals.DefaultPathSeparator)) { path = path.TrimEnd(StringLiterals.DefaultPathSeparator); originalPathHadTrailingSlash = true; @@ -608,7 +608,7 @@ namespace System.Management.Automation.Provider // See if the base and the path are already the same. We resolve this to // ..\Leaf, since resolving "." to "." doesn't offer much information. if (String.Equals(normalizedPath, normalizedBasePath, StringComparison.OrdinalIgnoreCase) && - (!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))) + (!originalPath.EndsWith(StringLiterals.DefaultPathSeparator))) { string childName = GetChildName(path); result = MakePath("..", childName); @@ -648,7 +648,7 @@ namespace System.Management.Automation.Provider if (!String.IsNullOrEmpty(commonBase)) { if (String.Equals(normalizedPath, commonBase, StringComparison.OrdinalIgnoreCase) && - (!normalizedPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))) + (!normalizedPath.EndsWith(StringLiterals.DefaultPathSeparator))) { string childName = GetChildName(path); result = MakePath("..", result);