diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs
index 470832670a9..9e063988b08 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs
@@ -588,7 +588,7 @@ private static bool IsOutOfBandView(ViewDefinition vd)
///
internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo appliesTo)
{
- Hashtable allTypes = new Hashtable(StringComparer.OrdinalIgnoreCase);
+ var allTypes = new HashSet(StringComparer.OrdinalIgnoreCase);
foreach (TypeOrGroupReference r in appliesTo.referenceList)
{
@@ -596,8 +596,8 @@ internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo a
TypeReference tr = r as TypeReference;
if (tr != null)
{
- if (!allTypes.ContainsKey(tr.name))
- allTypes.Add(tr.name, null);
+ if (!allTypes.Contains(tr.name))
+ allTypes.Add(tr.name);
}
else
{
@@ -616,16 +616,16 @@ internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo a
// we found the group, go over it
foreach (TypeReference x in tgd.typeReferenceList)
{
- if (!allTypes.ContainsKey(x.name))
- allTypes.Add(x.name, null);
+ if (!allTypes.Contains(x.name))
+ allTypes.Add(x.name);
}
}
}
AppliesTo retVal = new AppliesTo();
- foreach (DictionaryEntry x in allTypes)
+ foreach (string x in allTypes)
{
- retVal.AddAppliesToType(x.Key as string);
+ retVal.AddAppliesToType(x);
}
return retVal;
diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs
index bf3acfab2a1..e1af400ad51 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs
@@ -231,19 +231,19 @@ public List ResolveNames(PSObject target, bool expand)
}
}
- Hashtable hash = new Hashtable();
+ var allMembers = new HashSet();
// build the list of unique values: remove the possible duplicates
// from property set expansion
foreach (PSMemberInfo m in temporaryMemberList)
{
- if (!hash.ContainsKey(m.Name))
+ if (!allMembers.Contains(m.Name))
{
PSPropertyExpression ex = new PSPropertyExpression(m.Name);
ex._isResolved = true;
retVal.Add(ex);
- hash.Add(m.Name, null);
+ allMembers.Add(m.Name);
}
}
diff --git a/src/System.Management.Automation/help/AliasHelpProvider.cs b/src/System.Management.Automation/help/AliasHelpProvider.cs
index db7e4056d1e..670c0202bc7 100644
--- a/src/System.Management.Automation/help/AliasHelpProvider.cs
+++ b/src/System.Management.Automation/help/AliasHelpProvider.cs
@@ -141,7 +141,7 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
{
string target = helpRequest.Target;
string pattern = target;
- Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
+ var allAliases = new HashSet(StringComparer.OrdinalIgnoreCase);
if (!WildcardPattern.ContainsWildcardCharacters(target))
{
@@ -169,12 +169,12 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
continue;
}
- if (hashtable.ContainsKey(name))
+ if (allAliases.Contains(name))
{
continue;
}
- hashtable.Add(name, null);
+ allAliases.Add(name);
yield return helpInfo;
}
@@ -216,12 +216,12 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
continue;
}
- if (hashtable.ContainsKey(name))
+ if (allAliases.Contains(name))
{
continue;
}
- hashtable.Add(name, null);
+ allAliases.Add(name);
yield return helpInfo;
}
@@ -243,12 +243,12 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
HelpInfo helpInfo = AliasHelpInfo.GetHelpInfo(alias);
- if (hashtable.ContainsKey(name))
+ if (allAliases.Contains(name))
{
continue;
}
- hashtable.Add(name, null);
+ allAliases.Add(name);
yield return helpInfo;
}
diff --git a/src/System.Management.Automation/help/CommandHelpProvider.cs b/src/System.Management.Automation/help/CommandHelpProvider.cs
index 52e6b3e2916..aa3c1edb70e 100644
--- a/src/System.Management.Automation/help/CommandHelpProvider.cs
+++ b/src/System.Management.Automation/help/CommandHelpProvider.cs
@@ -427,7 +427,7 @@ internal override IEnumerable ExactMatchHelp(HelpRequest helpRequest)
int countHelpInfosFound = 0;
string target = helpRequest.Target;
// this is for avoiding duplicate result from help output.
- Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
+ var allHelpNames = new HashSet(StringComparer.OrdinalIgnoreCase);
CommandSearcher searcher = GetCommandSearcherForExactMatch(target, _context);
@@ -453,7 +453,7 @@ internal override IEnumerable ExactMatchHelp(HelpRequest helpRequest)
throw new PSInvalidOperationException(HelpErrors.CircularDependencyInHelpForwarding);
}
- if (hashtable.ContainsKey(helpName))
+ if (allHelpNames.Contains(helpName))
continue;
if (!Match(helpInfo, helpRequest, current))
@@ -462,7 +462,7 @@ internal override IEnumerable ExactMatchHelp(HelpRequest helpRequest)
}
countHelpInfosFound++;
- hashtable.Add(helpName, null);
+ allHelpNames.Add(helpName);
yield return helpInfo;
if ((countHelpInfosFound >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0))
@@ -1053,8 +1053,8 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
int countOfHelpInfoObjectsFound = 0;
// this is for avoiding duplicate result from help output.
- Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
- Hashtable hiddenCommands = new Hashtable(StringComparer.OrdinalIgnoreCase);
+ var set = new HashSet(StringComparer.OrdinalIgnoreCase);
+ var hiddenCommands = new HashSet(StringComparer.OrdinalIgnoreCase);
foreach (string pattern in patternList)
{
CommandSearcher searcher = GetCommandSearcherForSearch(pattern, _context);
@@ -1077,15 +1077,15 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
{
// this command is not visible to the user (from CommandOrigin) so
// dont show help topic for it.
- if (!hiddenCommands.ContainsKey(helpName))
+ if (!hiddenCommands.Contains(helpName))
{
- hiddenCommands.Add(helpName, null);
+ hiddenCommands.Add(helpName);
}
continue;
}
- if (hashtable.ContainsKey(helpName))
+ if (set.Contains(helpName))
continue;
// filter out the helpInfo object depending on user request
@@ -1100,7 +1100,7 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
continue;
}
- hashtable.Add(helpName, null);
+ set.Add(helpName);
countOfHelpInfoObjectsFound++;
yield return helpInfo;
@@ -1130,10 +1130,10 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
if (helpInfo != null && !string.IsNullOrEmpty(helpName))
{
- if (hashtable.ContainsKey(helpName))
+ if (set.Contains(helpName))
continue;
- if (hiddenCommands.ContainsKey(helpName))
+ if (hiddenCommands.Contains(helpName))
continue;
// filter out the helpInfo object depending on user request
@@ -1148,7 +1148,7 @@ internal override IEnumerable SearchHelp(HelpRequest helpRequest, bool
continue;
}
- hashtable.Add(helpName, null);
+ set.Add(helpName);
countOfHelpInfoObjectsFound++;
yield return helpInfo;