diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs index fd6a7fb7183..7b6a7c64d51 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs @@ -1294,7 +1294,7 @@ private string BuildStructuredQueryFromHashTable(EventLogSession eventLogSession string query = queriedLogsQueryMap[keyLogName]; result.Append(query); - if (query.EndsWith("*", StringComparison.OrdinalIgnoreCase)) + if (query.EndsWith('*')) { // // No provider predicate: just add the XPath string diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs index 78aecd0e160..f07356c287b 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs @@ -171,7 +171,7 @@ private string GetDrivePath(string driveName) { drivePath = driveName; } - else if (driveName.EndsWith(":", StringComparison.OrdinalIgnoreCase)) + else if (driveName.EndsWith(':')) { drivePath = driveName + "\\"; } diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs index c7a2d9e7514..36150e18e1c 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs @@ -1898,7 +1898,7 @@ internal static bool ContainsSystemDrive(string[] drives, string sysdrive) string driveApp; foreach (string drive in drives) { - if (!drive.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) + if (!drive.EndsWith('\\')) { driveApp = string.Concat(drive, "\\"); } diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/ResolvePathCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/ResolvePathCommand.cs index 9dece663f03..d0b96c57399 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/ResolvePathCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/ResolvePathCommand.cs @@ -123,7 +123,7 @@ protected override void ProcessRecord() // Do not insert './' if result path is not relative if (!adjustedPath.StartsWith( currentPath.Drive?.Root ?? currentPath.Path, StringComparison.OrdinalIgnoreCase) && - !adjustedPath.StartsWith(".", StringComparison.OrdinalIgnoreCase)) + !adjustedPath.StartsWith('.')) { adjustedPath = SessionState.Path.Combine(".", adjustedPath); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs index 7db4d3eb759..591ccd2577c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs @@ -1301,7 +1301,7 @@ internal void ReadHeader() values[0] = values[0].Substring(9); Header = values; } - else if (values.Count != 0 && values[0].StartsWith("#")) + else if (values.Count != 0 && values[0].StartsWith('#')) { // Skip all lines starting with '#' } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs index 4791100c68b..f5d9a1112c7 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs @@ -1160,7 +1160,7 @@ bool TryGetBoolValue(string arg, out bool boolValue) if (!System.IO.File.Exists(_file)) { - if (args[i].StartsWith("-") && args[i].Length > 1) + if (args[i].StartsWith('-') && args[i].Length > 1) { string param = args[i].Substring(1, args[i].Length - 1).ToLower(); StringBuilder possibleParameters = new StringBuilder(); diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 52dab0c2420..f04c932e71f 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -2969,7 +2969,7 @@ private string GetFilterString(Hashtable cmdlinevalues, string[] pkey) } } - if (filter.ToString().EndsWith("+", StringComparison.OrdinalIgnoreCase)) + if (filter.ToString().EndsWith('+')) filter.Remove(filter.ToString().Length - 1, 1); return filter.ToString(); } diff --git a/src/Microsoft.WSMan.Management/WsManHelper.cs b/src/Microsoft.WSMan.Management/WsManHelper.cs index d2bc116ebf4..81762a099f9 100644 --- a/src/Microsoft.WSMan.Management/WsManHelper.cs +++ b/src/Microsoft.WSMan.Management/WsManHelper.cs @@ -922,7 +922,7 @@ internal string GetURIWithFilter(string uri, string filter, Hashtable selectorse if (operation.Equals("remove", StringComparison.OrdinalIgnoreCase)) { sburi.Append(GetFilterString(selectorset)); - if (sburi.ToString().EndsWith("?", StringComparison.OrdinalIgnoreCase)) + if (sburi.ToString().EndsWith('?')) { sburi.Remove(sburi.Length - 1, 1); } diff --git a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs index ed2ef3ee80a..00e9ebb4bc7 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs @@ -887,7 +887,7 @@ internal static List PSv2GenerateMatchSetOfFiles(PowerShellExe lastWord = lastWord ?? string.Empty; bool isLastWordEmpty = string.IsNullOrEmpty(lastWord); - bool lastCharIsStar = !isLastWordEmpty && lastWord.EndsWith("*", StringComparison.Ordinal); + bool lastCharIsStar = !isLastWordEmpty && lastWord.EndsWith('*'); bool containsGlobChars = WildcardPattern.ContainsWildcardCharacters(lastWord); string wildWord = lastWord + "*"; @@ -1045,9 +1045,9 @@ private static bool PSv2ShouldFullyQualifyPathsPath(PowerShellExecutionHelper he { // These are special cases, as they represent cases where the user expects to // see the full path. - if (lastWord.StartsWith("~", StringComparison.OrdinalIgnoreCase) || - lastWord.StartsWith("\\", StringComparison.OrdinalIgnoreCase) || - lastWord.StartsWith("/", StringComparison.OrdinalIgnoreCase)) + if (lastWord.StartsWith('~') || + lastWord.StartsWith('\\') || + lastWord.StartsWith('/')) { return true; } diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs index 07b9b1b204f..b4e408ec224 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs @@ -387,7 +387,7 @@ internal List GetResultHelper(CompletionContext completionCont } // Handle scenarios like this: dir -path: - if (completionContext.WordToComplete.EndsWith(":", StringComparison.Ordinal)) + if (completionContext.WordToComplete.EndsWith(':')) { replacementIndex = tokenAtCursor.Extent.EndScriptPosition.Offset; replacementLength = 0; diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index a89994152f1..3e862a97822 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -427,7 +427,7 @@ internal static List CompleteModuleName(CompletionContext cont var result = new List(); var quote = HandleDoubleAndSingleQuote(ref moduleName); - if (!moduleName.EndsWith("*", StringComparison.Ordinal)) + if (!moduleName.EndsWith('*')) { moduleName += "*"; } @@ -507,7 +507,7 @@ internal static List CompleteCommandParameter(CompletionContex // If parent is DynamicKeywordStatementAst - 'Import-DscResource', // then customize the auto completion results if (keywordAst != null && string.Equals(keywordAst.Keyword.Keyword, "Import-DscResource", StringComparison.OrdinalIgnoreCase) - && !string.IsNullOrWhiteSpace(context.WordToComplete) && context.WordToComplete.StartsWith("-", StringComparison.OrdinalIgnoreCase)) + && !string.IsNullOrWhiteSpace(context.WordToComplete) && context.WordToComplete.StartsWith('-')) { var lastAst = context.RelatedAsts.Last(); var wordToMatch = context.WordToComplete.Substring(1) + "*"; @@ -536,7 +536,7 @@ internal static List CompleteCommandParameter(CompletionContex // Parent must be a command commandAst = (CommandAst)parameterAst.Parent; partialName = parameterAst.ParameterName; - withColon = context.WordToComplete.EndsWith(":", StringComparison.Ordinal); + withColon = context.WordToComplete.EndsWith(':'); } else { @@ -807,7 +807,7 @@ where pattern.IsMatch(alias) /// A list of completion results. public static List CompleteOperator(string wordToComplete) { - if (wordToComplete.StartsWith("-", StringComparison.Ordinal)) + if (wordToComplete.StartsWith('-')) { wordToComplete = wordToComplete.Substring(1); } @@ -846,7 +846,7 @@ internal static List CompleteCommandArgument(CompletionContext { commandAst = (CommandAst)expressionAst.Parent; - if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(",", StringComparison.Ordinal)) + if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(',')) { context.WordToComplete = string.Empty; // BUGBUG context.CursorPosition = expressionAst.Extent.StartScriptPosition; @@ -978,7 +978,7 @@ internal static List CompleteCommandArgument(CompletionContext else if (expressionAst.Parent is CommandParameterAst && expressionAst.Parent.Parent is CommandAst) { commandAst = (CommandAst)expressionAst.Parent.Parent; - if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(",", StringComparison.Ordinal)) + if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(',')) { // dir -Path: a.txt, context.WordToComplete = string.Empty; @@ -1228,7 +1228,7 @@ internal static List CompleteCommandArgument(CompletionContext secondToLastMemberAst.Extent.EndLineNumber == pathAst.Extent.StartLineNumber && secondToLastMemberAst.Extent.EndColumnNumber == pathAst.Extent.StartColumnNumber) { - var memberName = pathAst.Value.EndsWith("*", StringComparison.Ordinal) + var memberName = pathAst.Value.EndsWith('*') ? pathAst.Value : pathAst.Value + "*"; var targetExpr = secondToLastMemberAst.Expression; @@ -2911,7 +2911,7 @@ private static void NativeCompletionEventLogCommands(CompletionContext context, var logName = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref logName); - if (!logName.EndsWith("*", StringComparison.Ordinal)) + if (!logName.EndsWith('*')) { logName += "*"; } @@ -2962,7 +2962,7 @@ private static void NativeCompletionJobCommands(CompletionContext context, strin var wordToComplete = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref wordToComplete); - if (!wordToComplete.EndsWith("*", StringComparison.Ordinal)) + if (!wordToComplete.EndsWith('*')) { wordToComplete += "*"; } @@ -3049,7 +3049,7 @@ private static void NativeCompletionScheduledJobCommands(CompletionContext conte var wordToComplete = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref wordToComplete); - if (!wordToComplete.EndsWith("*", StringComparison.Ordinal)) + if (!wordToComplete.EndsWith('*')) { wordToComplete += "*"; } @@ -3183,7 +3183,7 @@ private static void NativeCompletionProcessCommands(CompletionContext context, s var wordToComplete = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref wordToComplete); - if (!wordToComplete.EndsWith("*", StringComparison.Ordinal)) + if (!wordToComplete.EndsWith('*')) { wordToComplete += "*"; } @@ -3274,7 +3274,7 @@ private static void NativeCompletionProviderCommands(CompletionContext context, var providerName = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref providerName); - if (!providerName.EndsWith("*", StringComparison.Ordinal)) + if (!providerName.EndsWith('*')) { providerName += "*"; } @@ -3318,7 +3318,7 @@ private static void NativeCompletionDriveCommands(CompletionContext context, str var wordToComplete = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref wordToComplete); - if (!wordToComplete.EndsWith("*", StringComparison.Ordinal)) + if (!wordToComplete.EndsWith('*')) { wordToComplete += "*"; } @@ -3365,7 +3365,7 @@ private static void NativeCompletionServiceCommands(CompletionContext context, s var wordToComplete = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref wordToComplete); - if (!wordToComplete.EndsWith("*", StringComparison.Ordinal)) + if (!wordToComplete.EndsWith('*')) { wordToComplete += "*"; } @@ -3451,7 +3451,7 @@ private static void NativeCompletionVariableCommands(CompletionContext context, var variableName = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref variableName); - if (!variableName.EndsWith("*", StringComparison.Ordinal)) + if (!variableName.EndsWith('*')) { variableName += "*"; } @@ -3511,7 +3511,7 @@ private static void NativeCompletionAliasCommands(CompletionContext context, str var commandName = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref commandName); - if (!commandName.EndsWith("*", StringComparison.Ordinal)) + if (!commandName.EndsWith('*')) { commandName += "*"; } @@ -3572,7 +3572,7 @@ private static void NativeCompletionTraceSourceCommands(CompletionContext contex var traceSourceName = context.WordToComplete ?? string.Empty; var quote = HandleDoubleAndSingleQuote(ref traceSourceName); - if (!traceSourceName.EndsWith("*", StringComparison.Ordinal)) + if (!traceSourceName.EndsWith('*')) { traceSourceName += "*"; } @@ -4008,7 +4008,7 @@ private static ArgumentLocation GenerateArgumentLocation(AstParameterArgumentPai if (!prev.ParameterSpecified) return new ArgumentLocation() { Argument = null, IsPositional = true, Position = position }; - return prev.Parameter.Extent.Text.EndsWith(":", StringComparison.Ordinal) + return prev.Parameter.Extent.Text.EndsWith(':') ? new ArgumentLocation() { Argument = prev, IsPositional = false, Position = -1 } : new ArgumentLocation() { Argument = null, IsPositional = true, Position = position }; @@ -4520,7 +4520,7 @@ internal static List GetFileShares(string machine, bool ignoreHidden) if ((shareInfo.type & STYPE_MASK) != STYPE_DISKTREE) continue; - if (ignoreHidden && shareInfo.netname.EndsWith("$", StringComparison.Ordinal)) + if (ignoreHidden && shareInfo.netname.EndsWith('$')) continue; shares.Add(shareInfo.netname); } @@ -6122,7 +6122,7 @@ internal static List CompleteStatementFlags(TokenKind kind, st Diagnostics.Assert(!string.IsNullOrEmpty(wordToComplete) && wordToComplete[0].IsDash(), "the word to complete should start with '-'"); wordToComplete = wordToComplete.Substring(1); - bool withColon = wordToComplete.EndsWith(":", StringComparison.Ordinal); + bool withColon = wordToComplete.EndsWith(':'); wordToComplete = withColon ? wordToComplete.Remove(wordToComplete.Length - 1) : wordToComplete; string enumString = LanguagePrimitives.EnumSingleTypeConverter.EnumValues(typeof(SwitchFlags)); diff --git a/src/System.Management.Automation/engine/CommandDiscovery.cs b/src/System.Management.Automation/engine/CommandDiscovery.cs index 1f71b2770fd..d5c639430cf 100644 --- a/src/System.Management.Automation/engine/CommandDiscovery.cs +++ b/src/System.Management.Automation/engine/CommandDiscovery.cs @@ -1182,7 +1182,7 @@ private static CommandInfo TryModuleAutoLoading(string commandName, ExecutionCon } } - if (string.IsNullOrEmpty(moduleName) || string.IsNullOrEmpty(moduleCommandName) || moduleName.EndsWith(".", StringComparison.Ordinal)) + if (string.IsNullOrEmpty(moduleName) || string.IsNullOrEmpty(moduleCommandName) || moduleName.EndsWith('.')) return null; bool etwEnabled = CommandDiscoveryEventSource.Log.IsEnabled(); @@ -1668,7 +1668,7 @@ internal Collection IndexOfRelativePath() { string path = this[index]; if (!string.IsNullOrEmpty(path) && - path.StartsWith(".", StringComparison.Ordinal)) + path.StartsWith('.')) { result.Add(index); } diff --git a/src/System.Management.Automation/engine/CommandInfo.cs b/src/System.Management.Automation/engine/CommandInfo.cs index 8787a3f1f98..00800ec0f2a 100644 --- a/src/System.Management.Automation/engine/CommandInfo.cs +++ b/src/System.Management.Automation/engine/CommandInfo.cs @@ -871,8 +871,8 @@ public Type Type { // We ignore the exception. if (Name != null && - Name.StartsWith("[", StringComparison.OrdinalIgnoreCase) && - Name.EndsWith("]", StringComparison.OrdinalIgnoreCase)) + Name.StartsWith('[') && + Name.EndsWith(']')) { string tmp = Name.Substring(1, Name.Length - 2); TypeResolver.TryResolveType(tmp, out _type); diff --git a/src/System.Management.Automation/engine/CommonCommandParameters.cs b/src/System.Management.Automation/engine/CommonCommandParameters.cs index 78530b6d063..e049fb52f2c 100644 --- a/src/System.Management.Automation/engine/CommonCommandParameters.cs +++ b/src/System.Management.Automation/engine/CommonCommandParameters.cs @@ -237,7 +237,7 @@ protected override void Validate(object arguments, EngineIntrinsics engineIntrin string varName = arguments as string; if (varName != null) { - if (varName.StartsWith("+", StringComparison.Ordinal)) + if (varName.StartsWith('+')) { varName = varName.Substring(1); } diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index a169a629cc4..ed7468cf56b 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -906,7 +906,7 @@ internal void SetupOutVariable() // as it needs to handle much of its OutVariable support itself. if ( (!string.IsNullOrEmpty(this.OutVariable)) && - (!(this.OutVariable.StartsWith("+", StringComparison.Ordinal))) && + (!(this.OutVariable.StartsWith('+'))) && string.Equals("Out-Default", _thisCommand.CommandInfo.Name, StringComparison.OrdinalIgnoreCase)) { if (_state == null) @@ -2492,7 +2492,7 @@ internal void SetupVariable(VariableStreamKind streamKind, string variableName, if (_state == null) _state = new SessionState(Context.EngineSessionState); - if (variableName.StartsWith("+", StringComparison.Ordinal)) + if (variableName.StartsWith('+')) { variableName = variableName.Substring(1); object oldValue = PSObject.Base(_state.PSVariable.GetValue(variableName)); diff --git a/src/System.Management.Automation/help/UpdatableHelpSystem.cs b/src/System.Management.Automation/help/UpdatableHelpSystem.cs index 987ee4ab7c5..68a3146424a 100644 --- a/src/System.Management.Automation/help/UpdatableHelpSystem.cs +++ b/src/System.Management.Automation/help/UpdatableHelpSystem.cs @@ -390,7 +390,7 @@ private string ResolveUri(string baseUri, bool verbose) // Like if you send a request to www.technet.com/powershell you will get // a 301/203 response with the response URI set to www.technet.com/powershell/ // - if (Directory.Exists(baseUri) || baseUri.EndsWith("/", StringComparison.OrdinalIgnoreCase)) + if (Directory.Exists(baseUri) || baseUri.EndsWith('/')) { if (verbose) { @@ -451,14 +451,14 @@ private string ResolveUri(string baseUri, bool verbose) _cmdlet.WriteVerbose(StringUtil.Format(RemotingErrorIdStrings.URIRedirectWarningToHost, uri)); } - if (uri.EndsWith("/", StringComparison.OrdinalIgnoreCase)) + if (uri.EndsWith('/')) { return uri; } } else if (response.StatusCode == HttpStatusCode.OK) { - if (uri.EndsWith("/", StringComparison.OrdinalIgnoreCase)) + if (uri.EndsWith('/')) { return uri; } @@ -1135,12 +1135,12 @@ private void UnzipHelpContent(ExecutionContext context, string srcPath, string d sucessfulDecompression = ExpandArchive(Path.Combine(sourceDirectory, Path.GetFileName(srcPath)), destPath); #else // Cabinet API doesn't handle the trailing back slash - if (!sourceDirectory.EndsWith("\\", StringComparison.Ordinal)) + if (!sourceDirectory.EndsWith('\\')) { sourceDirectory += "\\"; } - if (!destPath.EndsWith("\\", StringComparison.Ordinal)) + if (!destPath.EndsWith('\\')) { destPath += "\\"; } @@ -1651,7 +1651,7 @@ internal UpdatableHelpSystemDrive(PSCmdlet cmdlet, string path, PSCredential cre _cmdlet = cmdlet; // Need to get rid of the trailing \, otherwise New-PSDrive will not work... - if (path.EndsWith("\\", StringComparison.OrdinalIgnoreCase) || path.EndsWith("/", StringComparison.OrdinalIgnoreCase)) + if (path.EndsWith('\\') || path.EndsWith('/')) { path = path.Remove(path.Length - 1); } diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 3fcc23b040f..5e128db0e48 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -855,7 +855,7 @@ private static string WinGetSubstitutedPathForNetworkDosDevice(string driveName) associatedPath = associatedPath.Remove(0, 3); associatedPath = "\\" + associatedPath; } - else if (associatedPath.EndsWith(":", StringComparison.OrdinalIgnoreCase)) + else if (associatedPath.EndsWith(':')) { // The substed path is the root path of a drive. For example: subst Y: C:\ associatedPath += Path.DirectorySeparatorChar; diff --git a/src/System.Management.Automation/namespaces/LocationGlobber.cs b/src/System.Management.Automation/namespaces/LocationGlobber.cs index 82870358a65..c8ce50e3550 100644 --- a/src/System.Management.Automation/namespaces/LocationGlobber.cs +++ b/src/System.Management.Automation/namespaces/LocationGlobber.cs @@ -2287,7 +2287,7 @@ private bool HasRelativePathTokens(string path) comparePath.EndsWith("\\.", StringComparison.OrdinalIgnoreCase) || comparePath.StartsWith("..\\", StringComparison.OrdinalIgnoreCase) || comparePath.StartsWith(".\\", StringComparison.OrdinalIgnoreCase) || - comparePath.StartsWith("~", StringComparison.OrdinalIgnoreCase)); + comparePath.StartsWith('~')); } /// diff --git a/src/System.Management.Automation/namespaces/RegistryProvider.cs b/src/System.Management.Automation/namespaces/RegistryProvider.cs index 0de52140d06..02ef31e5518 100644 --- a/src/System.Management.Automation/namespaces/RegistryProvider.cs +++ b/src/System.Management.Automation/namespaces/RegistryProvider.cs @@ -2965,7 +2965,7 @@ private bool HasRelativePathTokens(string path) path.EndsWith("\\.", StringComparison.OrdinalIgnoreCase) || path.StartsWith("..\\", StringComparison.OrdinalIgnoreCase) || path.StartsWith(".\\", StringComparison.OrdinalIgnoreCase) || - path.StartsWith("~", StringComparison.OrdinalIgnoreCase)); + path.StartsWith('~')); } private void GetFilteredRegistryKeyProperties(string path, diff --git a/src/System.Management.Automation/utils/PathUtils.cs b/src/System.Management.Automation/utils/PathUtils.cs index 6c398af7494..da3d094bd01 100644 --- a/src/System.Management.Automation/utils/PathUtils.cs +++ b/src/System.Management.Automation/utils/PathUtils.cs @@ -357,7 +357,7 @@ internal static DirectoryInfo CreateModuleDirectory(PSCmdlet cmdlet, string modu try { string rootedPath = Microsoft.PowerShell.Commands.ModuleCmdletBase.ResolveRootedFilePath(moduleNameOrPath, cmdlet.Context); - if (string.IsNullOrEmpty(rootedPath) && moduleNameOrPath.StartsWith(".", StringComparison.OrdinalIgnoreCase)) + if (string.IsNullOrEmpty(rootedPath) && moduleNameOrPath.StartsWith('.')) { PathInfo currentPath = cmdlet.CurrentProviderLocation(cmdlet.Context.ProviderNames.FileSystem); rootedPath = Path.Combine(currentPath.ProviderPath, moduleNameOrPath);