Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -19,6 +19,10 @@ internal static class CommandHelpers
private static readonly ConcurrentDictionary<string, bool> s_nounExclusionList =
new ConcurrentDictionary<string, bool>();

// 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 ConcurrentDictionary<string, bool> s_cmdletExclusionList =
new ConcurrentDictionary<string, bool>();

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

Expand All @@ -27,15 +31,30 @@ internal static class CommandHelpers

static CommandHelpers()
{
s_nounExclusionList.TryAdd("Module", true);
// PowerShellGet v2 nouns
s_nounExclusionList.TryAdd("CredsFromCredentialProvider", true);
s_nounExclusionList.TryAdd("DscResource", true);
s_nounExclusionList.TryAdd("InstalledModule", true);
s_nounExclusionList.TryAdd("InstalledScript", true);
s_nounExclusionList.TryAdd("PSRepository", true);
s_nounExclusionList.TryAdd("RoleCapability", true);
s_nounExclusionList.TryAdd("Script", true);
s_nounExclusionList.TryAdd("ScriptFileInfo", true);

// PackageManagement nouns
s_nounExclusionList.TryAdd("Package", true);
s_nounExclusionList.TryAdd("PackageProvider", true);
s_nounExclusionList.TryAdd("PackageSource", true);
s_nounExclusionList.TryAdd("InstalledModule", true);
s_nounExclusionList.TryAdd("InstalledScript", true);
s_nounExclusionList.TryAdd("ScriptFileInfo", true);
s_nounExclusionList.TryAdd("PSRepository", true);

// Cmdlet's in PowerShellGet with conflicting nouns
s_cmdletExclusionList.TryAdd("Find-Command", true);
s_cmdletExclusionList.TryAdd("Find-Module", true);
s_cmdletExclusionList.TryAdd("Install-Module", true);
s_cmdletExclusionList.TryAdd("Publish-Module", true);
s_cmdletExclusionList.TryAdd("Save-Module", true);
s_cmdletExclusionList.TryAdd("Uninstall-Module", true);
s_cmdletExclusionList.TryAdd("Update-Module", true);
s_cmdletExclusionList.TryAdd("Update-ModuleManifest", true);
}

/// <summary>
Expand All @@ -57,12 +76,13 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
return cmdInfo;
}

// Make sure the command's noun isn't in the exclusion list. This is
// currently necessary to make sure that Get-Command doesn't
// load PackageManagement or PowerShellGet because they cause
// 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.ContainsKey(commandParts[1]))
if ((commandParts.Length == 2 && s_nounExclusionList.ContainsKey(commandParts[1]))
|| s_cmdletExclusionList.ContainsKey(commandName))
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -71,15 +70,13 @@ await _symbolsService.FindParameterSetsInFileAsync(
return new SignatureHelp();
}

SignatureInformation[] signatures = new SignatureInformation[parameterSets.Signatures.Length];
var signatures = new SignatureInformation[parameterSets.Signatures.Length];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

for (int i = 0; i < signatures.Length; i++)
{
var parameters = new ParameterInformation[parameterSets.Signatures[i].Parameters.Count()];
int j = 0;
var parameters = new List<ParameterInformation>();
foreach (ParameterInfo param in parameterSets.Signatures[i].Parameters)
{
parameters[j] = CreateParameterInfo(param);
j++;
parameters.Add(CreateParameterInfo(param));
}

signatures[i] = new SignatureInformation
Expand Down