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 @@ -391,10 +391,7 @@ private void ProcessListSetPerMachine(string machine)
Dictionary<string, string[]> counterInstanceMapping = new Dictionary<string, string[]>();
foreach (string counter in counterSetCounters)
{
if (!counterInstanceMapping.ContainsKey(counter))
{
counterInstanceMapping.Add(counter, instanceArray);
}
counterInstanceMapping.TryAdd(counter, instanceArray);
}

PerformanceCounterCategoryType categoryType = PerformanceCounterCategoryType.Unknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ public Collection<int> PromptForChoice(string caption,
defaultChoice);
}

if (!defaultChoiceKeys.ContainsKey(defaultChoice))
{
defaultChoiceKeys.Add(defaultChoice, true);
}
defaultChoiceKeys.TryAdd(defaultChoice, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ internal static List<MshResolvedExpressionParameterAssociation> ExpandAll(PSObje
List<MshResolvedExpressionParameterAssociation> retVal = new List<MshResolvedExpressionParameterAssociation>();
foreach (string property in displayedProperties)
{
if (!duplicatesFinder.ContainsKey(property))
if (duplicatesFinder.TryAdd(property, null))
{
duplicatesFinder.Add(property, null);
PSPropertyExpression expr = new PSPropertyExpression(property, true);
retVal.Add(new MshResolvedExpressionParameterAssociation(null, expr));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ internal string[] GetMemberNames(bool dataOnly)
{
foreach (string name in Events.Keys)
{
if (!names.ContainsKey(name))
{
names.Add(name, null);
}
names.TryAdd(name, null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,7 @@ private Collection<int> EmulatePromptForMultipleChoice(string caption,
defaultChoice);
}

if (!defaultChoiceKeys.ContainsKey(defaultChoice))
{
defaultChoiceKeys.Add(defaultChoice, true);
}
defaultChoiceKeys.TryAdd(defaultChoice, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ private static Tuple<Dictionary<string, object>, object[]> GetUsingValues(Ast bo

// Collect UsingExpression value as a dictionary
string usingAstKey = PsUtils.GetUsingExpressionKey(usingAst);
if (!usingValueMap.ContainsKey(usingAstKey))
{
usingValueMap.Add(usingAstKey, value);
}
usingValueMap.TryAdd(usingAstKey, value);
}
}
catch (RuntimeException rte)
Expand Down
3 changes: 1 addition & 2 deletions src/System.Management.Automation/security/CatalogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,8 @@ internal static void ProcessPathFile(FileInfo fileToHash, DirectoryInfo dirInfo,
fileHash = CalculateFileHash(fileToHash.FullName, hashAlgorithm);
}

if (!fileHashes.ContainsKey(relativePath))
if (fileHashes.TryAdd(relativePath, fileHash))
{
fileHashes.Add(relativePath, fileHash);
_cmdlet.WriteVerbose(StringUtil.Format(CatalogStrings.FoundFileInPath, relativePath, fileHash));
}
else
Expand Down