Skip to content

Remove unnecessary exclusions #1490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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 @@ -2,7 +2,6 @@
// Licensed under the MIT License.

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading.Tasks;
Expand All @@ -15,38 +14,6 @@ namespace Microsoft.PowerShell.EditorServices.Services.PowerShellContext
/// </summary>
internal static class CommandHelpers
{
private static readonly HashSet<string> s_nounExclusionList = new HashSet<string>
{
// PowerShellGet v2 nouns
"CredsFromCredentialProvider",
"DscResource",
"InstalledModule",
"InstalledScript",
"PSRepository",
"RoleCapability",
"Script",
"ScriptFileInfo",

// PackageManagement nouns
"Package",
"PackageProvider",
"PackageSource",
};

// This is used when a noun exists in multiple modules (for example, "Command" is used in Microsoft.PowerShell.Core and also PowerShellGet)
private static readonly HashSet<string> s_cmdletExclusionList = new HashSet<string>
{
// Commands in PowerShellGet with conflicting nouns
"Find-Command",
"Find-Module",
"Install-Module",
"Publish-Module",
"Save-Module",
"Uninstall-Module",
"Update-Module",
"Update-ModuleManifest",
};

private static readonly ConcurrentDictionary<string, CommandInfo> s_commandInfoCache =
new ConcurrentDictionary<string, CommandInfo>();

Expand All @@ -72,17 +39,6 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
return cmdInfo;
}

// Make sure the command's noun or command's name isn't in the exclusion lists.
// This is currently necessary to make sure that Get-Command doesn't
// load PackageManagement or PowerShellGet v2 because they cause
// a major slowdown in IntelliSense.
var commandParts = commandName.Split('-');
if ((commandParts.Length == 2 && s_nounExclusionList.Contains(commandParts[1]))
|| s_cmdletExclusionList.Contains(commandName))
{
return null;
}

PSCommand command = new PSCommand();
command.AddCommand(@"Microsoft.PowerShell.Core\Get-Command");
command.AddArgument(commandName);
Expand Down