Skip to content

Commit 5f3dd93

Browse files
authored
Use string.Contains(char) overload (#14368)
1 parent 1ab2c0c commit 5f3dd93

File tree

11 files changed

+12
-12
lines changed

11 files changed

+12
-12
lines changed

src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ internal static string GetLocalAdminUserName(string computerName, PSCredential p
17931793
string localUserName = null;
17941794

17951795
// The format of local admin username should be "ComputerName\AdminName"
1796-
if (psLocalCredential.UserName.Contains("\\"))
1796+
if (psLocalCredential.UserName.Contains('\\'))
17971797
{
17981798
localUserName = psLocalCredential.UserName;
17991799
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ private static bool IsSafeNameOrIdentifier(string name)
11281128
/// <returns><see langword="true"/> if the name is safe; <see langword="false"/> otherwise.</returns>
11291129
private static bool IsSafeParameterName(string parameterName)
11301130
{
1131-
return IsSafeNameOrIdentifier(parameterName) && !parameterName.Contains(":");
1131+
return IsSafeNameOrIdentifier(parameterName) && !parameterName.Contains(':');
11321132
}
11331133

11341134
/// <summary>

src/Microsoft.WSMan.Management/ConfigProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3573,7 +3573,7 @@ private string GetCorrectCaseOfName(string ChildName, string hostname, string pa
35733573
string result = ChildName;
35743574
if (ChildName != null)
35753575
{
3576-
if (!ChildName.Contains("_"))
3576+
if (!ChildName.Contains('_'))
35773577
{
35783578
if (ChildName.Equals(WSManStringLiterals.containerQuotasParameters, StringComparison.OrdinalIgnoreCase))
35793579
result = WSManStringLiterals.containerQuotasParameters;

src/Microsoft.WSMan.Management/WsManHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ internal static void LoadResourceData()
10921092
while (!_sr.EndOfStream)
10931093
{
10941094
string Line = _sr.ReadLine();
1095-
if (Line.Contains("="))
1095+
if (Line.Contains('='))
10961096
{
10971097
string[] arr = Line.Split('=', count: 2);
10981098
if (!ResourceValueCache.ContainsKey(arr[0].Trim()))

src/System.Management.Automation/DscSupport/CimDSCParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ public static void LoadResourcesFromModule(IScriptExtent scriptExtent,
21482148
}
21492149

21502150
// resource name without wildcard (*) should be imported only once
2151-
if (!resourceToImport.Contains("*") && foundResources)
2151+
if (!resourceToImport.Contains('*') && foundResources)
21522152
{
21532153
resourcesFound.Add(resourceToImport);
21542154
}
@@ -2170,7 +2170,7 @@ public static void LoadResourcesFromModule(IScriptExtent scriptExtent,
21702170
{
21712171
foreach (var resourceNameToImport in resourcesToImport)
21722172
{
2173-
if (!resourceNameToImport.Contains("*"))
2173+
if (!resourceNameToImport.Contains('*'))
21742174
{
21752175
errorList.Add(new ParseError(scriptExtent,
21762176
"DscResourcesNotFoundDuringParsing",

src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ internal static string FormatField(FieldFormattingDirective directive, object va
333333
{
334334
// use some heuristics to determine if we have "composite formatting"
335335
// 2004/11/16-JonN This is heuristic but should be safe enough
336-
if (directive.formatString.Contains("{0") || directive.formatString.Contains("}"))
336+
if (directive.formatString.Contains("{0") || directive.formatString.Contains('}'))
337337
{
338338
// we do have it, just use it
339339
return string.Format(CultureInfo.CurrentCulture, directive.formatString, so);

src/System.Management.Automation/engine/CommandDiscovery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ private static CommandInfo TryNormalSearch(string commandName,
994994
{
995995
if (!searcher.MoveNext())
996996
{
997-
if (!commandName.Contains("-") && !commandName.Contains("\\"))
997+
if (!commandName.Contains('-') && !commandName.Contains('\\'))
998998
{
999999
discoveryTracer.WriteLine(
10001000
"The command [{0}] was not found, trying again with get- prepended",

src/System.Management.Automation/engine/InternalCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2655,7 +2655,7 @@ public override object Transform(EngineIntrinsics engineIntrinsics, object input
26552655
return PSVersionInfo.PSVersion;
26562656
}
26572657

2658-
if (versionStr.Contains("."))
2658+
if (versionStr.Contains('.'))
26592659
{
26602660
// If the string contains a '.', let the Version constructor handle the conversion.
26612661
return inputData;

src/System.Management.Automation/engine/LanguagePrimitives.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ protected static object BaseConvertFrom(object sourceValue, Type destinationType
21332133
WildcardPattern[] fromValuePatterns;
21342134
if (!multipleValues)
21352135
{
2136-
if (sourceValueString.Contains(","))
2136+
if (sourceValueString.Contains(','))
21372137
{
21382138
throw new PSInvalidCastException("InvalidCastEnumCommaAndNoFlags", null,
21392139
ExtendedTypeSystem.InvalidCastExceptionEnumerationNoFlagAndComma,

src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,7 @@ public object[] ModulesToImport
23732373
// Add this check after checking if it a path
23742374
if (!string.IsNullOrEmpty(modulepath.Trim()))
23752375
{
2376-
if ((modulepath.Contains("\\") || modulepath.Contains(":")) &&
2376+
if ((modulepath.Contains('\\') || modulepath.Contains(':')) &&
23772377
!(Directory.Exists(modulepath) || File.Exists(modulepath)))
23782378
{
23792379
throw new ArgumentException(

0 commit comments

Comments
 (0)