GeezerVison is showing github.com — Code cleanup: use IndexOf(char) overload (#9722) · PowerShell/PowerShell@dd7e45f
File treeExpand file treeCollapse file tree Open diff view settings Microsoft.PowerShell.Commands.Management/commands/management System.Management.Automation
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1808,7 +1808,7 @@ internal static string GetLocalAdminUserName(string computerName, PSCredential p | 1808 | 1808 | } | 1809 | 1809 | else | 1810 | 1810 | { | 1811 | | - int dotIndex = computerName.IndexOf(".", StringComparison.OrdinalIgnoreCase); | | 1811 | + int dotIndex = computerName.IndexOf('.'); | 1812 | 1812 | if (dotIndex == -1) | 1813 | 1813 | { | 1814 | 1814 | localUserName = computerName + "\\" + psLocalCredential.UserName; | |
Collapse file Copy file name to clipboardExpand all lines: src/Microsoft.PowerShell.Commands.Management/commands/management/ControlPanelItemCommand.cs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -227,7 +227,7 @@ private static bool CompareVerbActionOpen(string verbActionName) | 227 | 227 | { | 228 | 228 | string canonicalName = (string)item.ExtendedProperty("System.ApplicationName"); | 229 | 229 | canonicalName = !string.IsNullOrEmpty(canonicalName) | 230 | | - ? canonicalName.Substring(0, canonicalName.IndexOf("\0", StringComparison.OrdinalIgnoreCase)) | | 230 | + ? canonicalName.Substring(0, canonicalName.IndexOf('\0')) | 231 | 231 | : null; | 232 | 232 |
| 233 | 233 | if (canonicalName != null && canonicalName.Equals(RegionCanonicalName, StringComparison.OrdinalIgnoreCase)) | @@ -452,7 +452,7 @@ internal List<ShellFolderItem> GetControlPanelItemByCanonicalName(List<ShellFold | 452 | 452 | string path = item.Path; | 453 | 453 | string canonicalName = (string)item.ExtendedProperty("System.ApplicationName"); | 454 | 454 | canonicalName = canonicalName != null | 455 | | - ? canonicalName.Substring(0, canonicalName.IndexOf("\0", StringComparison.OrdinalIgnoreCase)) | | 455 | + ? canonicalName.Substring(0, canonicalName.IndexOf('\0')) | 456 | 456 | : null; | 457 | 457 |
| 458 | 458 | if (canonicalName == null) | @@ -640,7 +640,7 @@ protected override void ProcessRecord() | 640 | 640 | string description = (string)item.ExtendedProperty("InfoTip"); | 641 | 641 | string canonicalName = (string)item.ExtendedProperty("System.ApplicationName"); | 642 | 642 | canonicalName = canonicalName != null | 643 | | - ? canonicalName.Substring(0, canonicalName.IndexOf("\0", StringComparison.OrdinalIgnoreCase)) | | 643 | + ? canonicalName.Substring(0, canonicalName.IndexOf('\0')) | 644 | 644 | : null; | 645 | 645 | int[] categories = (int[])item.ExtendedProperty("System.ControlPanel.Category"); | 646 | 646 | string[] cateStrings = new string[categories.Length]; | |
Collapse file Copy file name to clipboardExpand all lines: src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -300,7 +300,7 @@ protected override void ProcessRecord() | 300 | 300 | continue; | 301 | 301 |
| 302 | 302 | case qualifierSet: | 303 | | - int separatorIndex = pathsToParse[index].IndexOf(":", StringComparison.CurrentCulture); | | 303 | + int separatorIndex = pathsToParse[index].IndexOf(':'); | 304 | 304 |
| 305 | 305 | if (separatorIndex < 0) | 306 | 306 | { | @@ -449,7 +449,7 @@ private string RemoveQualifier(string path) | 449 | 449 |
| 450 | 450 | if (SessionState.Path.IsProviderQualified(path)) | 451 | 451 | { | 452 | | - int index = path.IndexOf("::", StringComparison.CurrentCulture); | | 452 | + int index = path.IndexOf("::", StringComparison.Ordinal); | 453 | 453 |
| 454 | 454 | if (index != -1) | 455 | 455 | { | |
Collapse file Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -6600,7 +6600,7 @@ internal static void CompleteMemberHelper( | 6600 | 6600 | } | 6601 | 6601 |
| 6602 | 6602 | string tooltip = memberInfo.ToString(); | 6603 | | - if (tooltip.IndexOf("),", StringComparison.OrdinalIgnoreCase) != -1) | | 6603 | + if (tooltip.IndexOf("),", StringComparison.Ordinal) != -1) | 6604 | 6604 | { | 6605 | 6605 | var overloads = tooltip.Split(new[] { ")," }, StringSplitOptions.RemoveEmptyEntries); | 6606 | 6606 | var newTooltip = new StringBuilder(); | |
Collapse file Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/LanguagePrimitives.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1505,7 +1505,7 @@ internal static object GetConverter(Type type, TypeTable backupTypeTable) | 1505 | 1505 |
| 1506 | 1506 | private static object NewConverterInstance(string assemblyQualifiedTypeName) | 1507 | 1507 | { | 1508 | | - int typeSeparator = assemblyQualifiedTypeName.IndexOf(",", StringComparison.Ordinal); | | 1508 | + int typeSeparator = assemblyQualifiedTypeName.IndexOf(','); | 1509 | 1509 | if (typeSeparator == -1) | 1510 | 1510 | { | 1511 | 1511 | typeConversion.WriteLine("Type name \"{0}\" should be assembly qualified.", assemblyQualifiedTypeName); | |
Collapse file Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -4680,7 +4680,7 @@ internal static bool IsRooted(string filePath) | 4680 | 4680 | filePath.StartsWith(@"../", StringComparison.Ordinal) || | 4681 | 4681 | filePath.StartsWith(@"~/", StringComparison.Ordinal) || | 4682 | 4682 | filePath.StartsWith(@"~\", StringComparison.Ordinal) || | 4683 | | - filePath.IndexOf(":", StringComparison.Ordinal) >= 0); | | 4683 | + filePath.Contains(':')); | 4684 | 4684 | } | 4685 | 4685 |
| 4686 | 4686 | /// <summary> | |
Collapse file Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/ParameterSetInfo.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -292,7 +292,7 @@ internal static string GetParameterTypeString(Type type, IEnumerable<Attribute> | 292 | 292 | } | 293 | 293 |
| 294 | 294 | // If the type is really an array, but the typename didn't include [], then add it. | 295 | | - if (type.IsArray && (parameterTypeString.IndexOf("[]", StringComparison.OrdinalIgnoreCase) == -1)) | | 295 | + if (type.IsArray && (parameterTypeString.IndexOf("[]", StringComparison.Ordinal) == -1)) | 296 | 296 | { | 297 | 297 | var t = type; | 298 | 298 | while (t.IsArray) | |
Collapse file Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/parser/ast.cs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8349,7 +8349,7 @@ internal Type GetGenericType(Type generic) | 8349 | 8349 | { | 8350 | 8350 | if (generic == null || !generic.ContainsGenericParameters) | 8351 | 8351 | { | 8352 | | - if (TypeName.FullName.IndexOf("`", StringComparison.OrdinalIgnoreCase) == -1) | | 8352 | + if (!TypeName.FullName.Contains('`')) | 8353 | 8353 | { | 8354 | 8354 | var newTypeName = new TypeName(Extent, | 8355 | 8355 | string.Format(CultureInfo.InvariantCulture, "{0}`{1}", TypeName.FullName, GenericArguments.Count)); | @@ -8376,7 +8376,7 @@ public Type GetReflectionAttributeType() | 8376 | 8376 | Type generic = TypeName.GetReflectionAttributeType(); | 8377 | 8377 | if (generic == null || !generic.ContainsGenericParameters) | 8378 | 8378 | { | 8379 | | - if (TypeName.FullName.IndexOf("`", StringComparison.OrdinalIgnoreCase) == -1) | | 8379 | + if (!TypeName.FullName.Contains('`')) | 8380 | 8380 | { | 8381 | 8381 | var newTypeName = new TypeName(Extent, | 8382 | 8382 | string.Format(CultureInfo.InvariantCulture, "{0}Attribute`{1}", TypeName.FullName, GenericArguments.Count)); | |
Collapse file Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -5436,7 +5436,7 @@ protected override void BeginProcessing() | 5436 | 5436 |
| 5437 | 5437 | if (!string.IsNullOrEmpty(this.Username)) | 5438 | 5438 | { | 5439 | | - if (this.Username.IndexOf("\\", StringComparison.OrdinalIgnoreCase) >= 0) | | 5439 | + if (this.Username.Contains('\\')) | 5440 | 5440 | { | 5441 | 5441 | validator = null; | 5442 | 5442 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1285,8 +1285,8 @@ private void UpdateUri(Uri uri) | 1285 | 1285 | (RemotingErrorIdStrings.RelativeUriForRunspacePathNotSupported)); | 1286 | 1286 | } | 1287 | 1287 |
| 1288 | | - if (uri.OriginalString.LastIndexOf(":", StringComparison.OrdinalIgnoreCase) > | 1289 | | - uri.AbsoluteUri.IndexOf("//", StringComparison.OrdinalIgnoreCase)) | | 1288 | + if (uri.OriginalString.LastIndexOf(':') > | | 1289 | + uri.AbsoluteUri.IndexOf("//", StringComparison.Ordinal)) | 1290 | 1290 | { | 1291 | 1291 | UseDefaultWSManPort = false; | 1292 | 1292 | } | @@ -1296,7 +1296,7 @@ private void UpdateUri(Uri uri) | 1296 | 1296 | // http://localhost , http://127.0.0.1 etc. | 1297 | 1297 | string appname; | 1298 | 1298 |
| 1299 | | - if (uri.AbsolutePath.Equals("/", StringComparison.OrdinalIgnoreCase) && | | 1299 | + if (uri.AbsolutePath.Equals("/", StringComparison.Ordinal) && | 1300 | 1300 | string.IsNullOrEmpty(uri.Query) && string.IsNullOrEmpty(uri.Fragment)) | 1301 | 1301 | { | 1302 | 1302 | appname = s_defaultAppName; | |
|