Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public override void WriteObject(object sendToPipeline, XOperationContextBase co
CimSetCimInstanceContext setContext = context as CimSetCimInstanceContext;
if (setContext != null)
{
if ((string.Compare(setContext.ParameterSetName, CimBaseCommand.QueryComputerSet, StringComparison.OrdinalIgnoreCase) == 0) ||
(string.Compare(setContext.ParameterSetName, CimBaseCommand.QuerySessionSet, StringComparison.OrdinalIgnoreCase) == 0))
if (string.Equals(setContext.ParameterSetName, CimBaseCommand.QueryComputerSet, StringComparison.OrdinalIgnoreCase) ||
string.Equals(setContext.ParameterSetName, CimBaseCommand.QuerySessionSet, StringComparison.OrdinalIgnoreCase))
{
this.setCimInstance.SetCimInstance(sendToPipeline as CimInstance, setContext, this);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public static string[] ValidateArgumentIsValidName(string parameterName, string[
foreach (string propertyName in value)
{
// * is wild char supported in select properties
if ((propertyName != null) && (string.Compare(propertyName.Trim(), "*", StringComparison.OrdinalIgnoreCase) == 0))
if ((propertyName != null) && string.Equals(propertyName.Trim(), "*", StringComparison.OrdinalIgnoreCase))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ internal void AddTextToParagraphBuilder()

HelpCategory category = HelpCategory.Default;

if (string.Compare(strCategory, "DscResource", StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(strCategory, "DscResource", StringComparison.OrdinalIgnoreCase))
{
category = HelpCategory.DscResource;
}
else if (string.Compare(strCategory, "Class", StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Equals(strCategory, "Class", StringComparison.OrdinalIgnoreCase))
{
category = HelpCategory.Class;
}
Expand Down Expand Up @@ -594,7 +594,7 @@ private void AddMembers(bool setting, string sectionTitle)
string type = GetPropertyString(member, "type");
string propertyType = null;

if (string.Compare("field", type, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals("field", type, StringComparison.OrdinalIgnoreCase))
{
PSObject fieldData = HelpParagraphBuilder.GetPropertyObject(member, "fieldData") as PSObject;

Expand All @@ -610,7 +610,7 @@ private void AddMembers(bool setting, string sectionTitle)
memberText = string.Format(CultureInfo.CurrentCulture, " [{0}] {1}\r\n", propertyType, name);
}
}
else if (string.Compare("method", type, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Equals("method", type, StringComparison.OrdinalIgnoreCase))
{
FormatMethodData(member, name, out memberText, out description);
}
Expand Down Expand Up @@ -702,7 +702,7 @@ private static void FormatMethodData(PSObject member, string name, out string me
parameterText.Append(paramString);
}

if (string.Compare(parameterText[parameterText.Length - 1].ToString(), ",", StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(parameterText[parameterText.Length - 1].ToString(), ",", StringComparison.OrdinalIgnoreCase))
{
parameterText = parameterText.Remove(parameterText.Length - 1, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ private int Compare(ParameterSetViewModel source, ParameterSetViewModel target)
}
}

return string.Compare(source.Name, target.Name, StringComparison.Ordinal);
return string.CompareOrdinal(source.Name, target.Name);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ protected override void ProcessRecord()
break;

default:
Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Invalid parameter set name: {0}", ParameterSetName));
Debug.Fail(string.Format(CultureInfo.InvariantCulture, "Invalid parameter set name: {0}", ParameterSetName));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public override bool ShouldReportErrorOnNoMatches_IfMultipleFilters()
case BehaviorOnNoMatch.Default:
default:
return this.PropertyValueFilters
.Where(f => !f.HadMatch).Any(f => f.BehaviorOnNoMatch == BehaviorOnNoMatch.ReportErrors);
.Any(f => !f.HadMatch && f.BehaviorOnNoMatch == BehaviorOnNoMatch.ReportErrors);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private bool ValidDrivePath(string drivePath)
{
foreach (DriveInfo drive in _availableDrives)
{
if (string.Compare(drive.Name, drivePath, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(drive.Name, drivePath, StringComparison.OrdinalIgnoreCase))
{
actualDrive = drive;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ private List<string> TestRestartStageUsingWsman(IEnumerable<string> computerName
string newLastBootUpTime = os.CimInstanceProperties["LastBootUpTime"].Value.ToString();
string oldLastBootUpTime = _computerInfos[computer].LastBootUpTime;

if (string.Compare(newLastBootUpTime, oldLastBootUpTime, StringComparison.OrdinalIgnoreCase) != 0)
if (!string.Equals(newLastBootUpTime, oldLastBootUpTime, StringComparison.OrdinalIgnoreCase))
{
_computerInfos[computer].RebootComplete = true;
nextTestList.Add(computer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,10 @@ internal void WriteContentObject(object content, long readCount, PathInfo pathIn

if (_currentContentItem != null &&
((_currentContentItem.PathInfo == pathInfo) ||
(
string.Compare(
string.Equals(
pathInfo.Path,
_currentContentItem.PathInfo.Path,
StringComparison.OrdinalIgnoreCase) == 0)
)
)
StringComparison.OrdinalIgnoreCase)))
{
result = _currentContentItem.AttachNotes(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,9 @@ private static List<string> CollectPropertyNames(string[] requestedProperties)
// find a matching property name via case-insensitive string comparison
Predicate<string> pred = (s) =>
{
return string.Compare(s,
return string.Equals(s,
name,
StringComparison.OrdinalIgnoreCase) == 0;
StringComparison.OrdinalIgnoreCase);
};
var propertyName = availableProperties.Find(pred);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ protected override void ProcessRecord()
return false;
}

return string.Compare(
return string.Equals(
SessionState.Path.GetUnresolvedProviderPathFromPSPath(breakpoint.Script),
SessionState.Path.GetUnresolvedProviderPathFromPSPath(script),
StringComparison.OrdinalIgnoreCase
) == 0;
);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override void ProcessRecord()
_lastObjectAsString = _lastObject.ToString();
}

if (0 == string.Compare(
if (string.Equals(
inputString,
_lastObjectAsString,
StringComparison.CurrentCulture))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ private bool IsMeasuringGeneric
{
get
{
return string.Compare(ParameterSetName, GenericParameterSet, StringComparison.Ordinal) == 0;
return string.Equals(ParameterSetName, GenericParameterSet, StringComparison.Ordinal);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected override void BeginProcessing()
Type type = null;
PSArgumentException mshArgE = null;

if (string.Compare(ParameterSetName, netSetName, StringComparison.Ordinal) == 0)
if (string.Equals(ParameterSetName, netSetName, StringComparison.Ordinal))
{
object _newObject = null;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private static PSObject PopulateFromJDictionary(JObject entries, DuplicateMember
// 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.Ordinal) == 0)
&& string.Equals(entry.Key, maybePropertyName, StringComparison.Ordinal))
{
var errorMsg = string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.DuplicateKeysInJsonString, entry.Key);
error = new ErrorRecord(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,13 @@ private string PromptCommandMode(string input, FieldDescription desc, out bool i

if (command.Length == 2)
{
if (0 == string.Compare(command, "\"\"", StringComparison.OrdinalIgnoreCase))
if (string.Equals(command, "\"\"", StringComparison.OrdinalIgnoreCase))
{
return string.Empty;
}
}

if (0 == string.Compare(command, "$null", StringComparison.OrdinalIgnoreCase))
if (string.Equals(command, "$null", StringComparison.OrdinalIgnoreCase))
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class WrappedDeserializer : Serialization

textReader = input;
_firstLine = textReader.ReadLine();
if (string.Compare(_firstLine, Serialization.XmlCliTag, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(_firstLine, Serialization.XmlCliTag, StringComparison.OrdinalIgnoreCase))
{
// format should be XML

Expand Down
18 changes: 9 additions & 9 deletions src/System.Management.Automation/DscSupport/CimDSCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ private static CimClass MyClassCallback(string serverName, string namespaceName,
foreach (KeyValuePair<string, DscClassCacheEntry> cimClass in ClassCache)
{
string cachedClassName = cimClass.Key.Split(Utils.Separators.Backslash)[IndexClassName];
if (string.Compare(cachedClassName, className, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(cachedClassName, className, StringComparison.OrdinalIgnoreCase))
{
return cimClass.Value.CimClassInstance;
}
Expand Down Expand Up @@ -1107,9 +1107,9 @@ private static List<KeyValuePair<string, DscClassCacheEntry>> FindResourceInCach
let cachedClassName = splittedName[IndexClassName]
let cachedModuleName = splittedName[IndexModuleName]
let cachedResourceName = splittedName[IndexFriendlyName]
where ((string.Compare(cachedResourceName, resourceName, StringComparison.OrdinalIgnoreCase) == 0)
|| (string.Compare(cachedClassName, className, StringComparison.OrdinalIgnoreCase) == 0
&& string.Compare(cachedModuleName, moduleName, StringComparison.OrdinalIgnoreCase) == 0))
where (string.Equals(cachedResourceName, resourceName, StringComparison.OrdinalIgnoreCase)
|| (string.Equals(cachedClassName, className, StringComparison.OrdinalIgnoreCase)
&& string.Equals(cachedModuleName, moduleName, StringComparison.OrdinalIgnoreCase)))
select cacheEntry).ToList();
}

Expand Down Expand Up @@ -1153,7 +1153,7 @@ public static List<string> GetFileDefiningClass(string className)
{
var file = pair.Key;
var classList = pair.Value;
if (classList != null && classList.FirstOrDefault((CimClass c) => string.Equals(c.CimSystemProperties.ClassName, className, StringComparison.OrdinalIgnoreCase)) != null)
if (classList != null && classList.Find((CimClass c) => string.Equals(c.CimSystemProperties.ClassName, className, StringComparison.OrdinalIgnoreCase)) != null)
{
files.Add(file);
}
Expand Down Expand Up @@ -1553,11 +1553,11 @@ private static DynamicKeyword CreateKeywordFromCimClass(string moduleName, Versi
private static void UpdateKnownRestriction(DynamicKeyword keyword)
{
if (
string.Compare(keyword.ResourceName, "MSFT_DSCMetaConfigurationV2",
StringComparison.OrdinalIgnoreCase) == 0
string.Equals(keyword.ResourceName, "MSFT_DSCMetaConfigurationV2",
StringComparison.OrdinalIgnoreCase)
||
string.Compare(keyword.ResourceName, "MSFT_DSCMetaConfiguration",
StringComparison.OrdinalIgnoreCase) == 0)
string.Equals(keyword.ResourceName, "MSFT_DSCMetaConfiguration",
StringComparison.OrdinalIgnoreCase))
{
if (keyword.Properties["RefreshFrequencyMins"] != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ private static ControlBody ResolveControlReferenceInList(ControlReference contro
{
if (x.controlBody.GetType() != controlReference.controlType)
continue;
if (string.Compare(controlReference.name, x.name, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(controlReference.name, x.name, StringComparison.OrdinalIgnoreCase))
return x.controlBody;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private static bool IsEqual(object first, object second)
string firstString = PSObject.AsPSObject(first).ToString();
string secondString = PSObject.AsPSObject(second).ToString();

return string.Compare(firstString, secondString, StringComparison.CurrentCultureIgnoreCase) == 0;
return string.Equals(firstString, secondString, StringComparison.CurrentCultureIgnoreCase);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void ProcessUnknownInvalidClassId(string classId, object obj, string err
#region Helper Methods
private static bool IsClass(string x, string y)
{
return string.Compare(x, y, StringComparison.OrdinalIgnoreCase) == 0;
return string.Equals(x, y, StringComparison.OrdinalIgnoreCase);
}

#if _UNUSED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal ScriptBlock ParseScriptBlock(string script, string fileName, bool addTo
EngineParser.SetPreviousFirstLastToken(Context);
}

if (errors.Any())
if (errors.Length > 0)
{
if (errors[0].IncompleteInput)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,10 +854,10 @@ private static void PrependSnapInNameForSameCmdletNames(CommandAndName[] cmdlets

CommandAndName nextCommandAndName = cmdlets[lookAhead];

if (string.Compare(
if (string.Equals(
commandAndName.CommandName.ShortName,
nextCommandAndName.CommandName.ShortName,
StringComparison.OrdinalIgnoreCase) == 0)
StringComparison.OrdinalIgnoreCase))
{
AddCommandResult(commandAndName, true, completingAtStartOfLine, quote, results);
previousMatched = true;
Expand Down Expand Up @@ -998,7 +998,7 @@ private static IEnumerable<PathItemAndConvertedPath> CombineMatchSets(List<PathI
result.AddRange(s1);
for (int i = 0, j = 0; i < s2.Count; ++i)
{
if (j < s1.Count && string.Compare(s2[i].Path, s1[j].Path, StringComparison.CurrentCultureIgnoreCase) == 0)
if (j < s1.Count && string.Equals(s2[i].Path, s1[j].Path, StringComparison.CurrentCultureIgnoreCase))
{
++j;
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ private List<CompletionResult> GetResultForIdentifierInConfiguration(

IEnumerable<DynamicKeyword> keywords = configureAst.DefinedKeywords.Where(
k => // Node is special case, legal in both Resource and Meta configuration
string.Compare(k.Keyword, @"Node", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Equals(k.Keyword, @"Node", StringComparison.OrdinalIgnoreCase) ||
(
// Check compatibility between Resource and Configuration Type
k.IsCompatibleWithConfigurationType(configureAst.ConfigurationType) &&
Expand Down Expand Up @@ -1954,7 +1954,7 @@ private List<CompletionResult> GetResultForIdentifier(CompletionContext completi
// If the last token was just a '.', we tried to complete members. That may
// have failed because it wasn't really an attempt to complete a member, in
// which case we should try to complete as an argument.
if (result.Any())
if (result.Count > 0)
{
if (!isWildcard && memberOperator != TokenKind.Unknown)
{
Expand All @@ -1969,7 +1969,7 @@ private List<CompletionResult> GetResultForIdentifier(CompletionContext completi
if (lastAst.Parent is HashtableAst)
{
result = CompletionCompleters.CompleteHashtableKey(completionContext, (HashtableAst)lastAst.Parent);
if (result != null && result.Any())
if (result != null && result.Count > 0)
{
return result;
}
Expand All @@ -1992,7 +1992,7 @@ private List<CompletionResult> GetResultForIdentifier(CompletionContext completi
else if (tokenAtCursorText.IndexOfAny(Utils.Separators.Directory) == 0)
{
var command = lastAst.Parent as CommandBaseAst;
if (command != null && command.Redirections.Any())
if (command != null && command.Redirections.Count > 0)
{
var fileRedirection = command.Redirections[0] as FileRedirectionAst;
if (fileRedirection != null &&
Expand Down
Loading