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 @@ -588,16 +588,16 @@ private static bool IsOutOfBandView(ViewDefinition vd)
/// <returns></returns>
internal static AppliesTo GetAllApplicableTypes(TypeInfoDataBase db, AppliesTo appliesTo)
{
Hashtable allTypes = new Hashtable(StringComparer.OrdinalIgnoreCase);
var allTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

foreach (TypeOrGroupReference r in appliesTo.referenceList)
{
// if it is a type reference, just add the type name
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
{
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,19 @@ public List<PSPropertyExpression> ResolveNames(PSObject target, bool expand)
}
}

Hashtable hash = new Hashtable();
var allMembers = new HashSet<string>();

// 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);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/System.Management.Automation/help/AliasHelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ internal override IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest, bool
{
string target = helpRequest.Target;
string pattern = target;
Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
var allAliases = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

if (!WildcardPattern.ContainsWildcardCharacters(target))
{
Expand Down Expand Up @@ -169,12 +169,12 @@ internal override IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest, bool
continue;
}

if (hashtable.ContainsKey(name))
if (allAliases.Contains(name))
{
continue;
}

hashtable.Add(name, null);
allAliases.Add(name);

yield return helpInfo;
}
Expand Down Expand Up @@ -216,12 +216,12 @@ internal override IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest, bool
continue;
}

if (hashtable.ContainsKey(name))
if (allAliases.Contains(name))
{
continue;
}

hashtable.Add(name, null);
allAliases.Add(name);

yield return helpInfo;
}
Expand All @@ -243,12 +243,12 @@ internal override IEnumerable<HelpInfo> 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;
}
Expand Down
24 changes: 12 additions & 12 deletions src/System.Management.Automation/help/CommandHelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ internal override IEnumerable<HelpInfo> 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<string>(StringComparer.OrdinalIgnoreCase);

CommandSearcher searcher = GetCommandSearcherForExactMatch(target, _context);

Expand All @@ -453,7 +453,7 @@ internal override IEnumerable<HelpInfo> ExactMatchHelp(HelpRequest helpRequest)
throw new PSInvalidOperationException(HelpErrors.CircularDependencyInHelpForwarding);
}

if (hashtable.ContainsKey(helpName))
if (allHelpNames.Contains(helpName))
continue;

if (!Match(helpInfo, helpRequest, current))
Expand All @@ -462,7 +462,7 @@ internal override IEnumerable<HelpInfo> ExactMatchHelp(HelpRequest helpRequest)
}

countHelpInfosFound++;
hashtable.Add(helpName, null);
allHelpNames.Add(helpName);
yield return helpInfo;

if ((countHelpInfosFound >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0))
Expand Down Expand Up @@ -1053,8 +1053,8 @@ internal override IEnumerable<HelpInfo> 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<string>(StringComparer.OrdinalIgnoreCase);
var hiddenCommands = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (string pattern in patternList)
{
CommandSearcher searcher = GetCommandSearcherForSearch(pattern, _context);
Expand All @@ -1077,15 +1077,15 @@ internal override IEnumerable<HelpInfo> 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
Expand All @@ -1100,7 +1100,7 @@ internal override IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest, bool
continue;
}

hashtable.Add(helpName, null);
set.Add(helpName);
countOfHelpInfoObjectsFound++;
yield return helpInfo;

Expand Down Expand Up @@ -1130,10 +1130,10 @@ internal override IEnumerable<HelpInfo> 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
Expand All @@ -1148,7 +1148,7 @@ internal override IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest, bool
continue;
}

hashtable.Add(helpName, null);
set.Add(helpName);
countOfHelpInfoObjectsFound++;
yield return helpInfo;

Expand Down