Skip to content

Commit f791030

Browse files
fix test and remove dynamic code
1 parent ca80bdf commit f791030

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetCommandHandler.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public async Task<List<PSCommandMessage>> Handle(GetCommandParams request, Cance
6363
.AddCommand("Microsoft.PowerShell.Utility\\Sort-Object")
6464
.AddParameter("Property", "Name");
6565

66-
IEnumerable<PSObject> result = await _powerShellContextService.ExecuteCommandAsync<PSObject>(psCommand).ConfigureAwait(false);
66+
IEnumerable<CommandInfo> result = await _powerShellContextService.ExecuteCommandAsync<CommandInfo>(psCommand).ConfigureAwait(false);
6767

6868
var commandList = new List<PSCommandMessage>();
6969
if (result != null)
7070
{
71-
foreach (dynamic command in result)
71+
foreach (CommandInfo command in result)
7272
{
7373
if (!_skipPackageManagementCheck && command.ModuleName == "PackageManagement" && command.Version < new Version(1, 4, 6))
7474
{
@@ -129,13 +129,24 @@ public async Task<List<PSCommandMessage>> Handle(GetCommandParams request, Cance
129129
}
130130
}
131131

132+
// Get the default ParameterSet
133+
string defaultParameterSet = null;
134+
foreach (CommandParameterSetInfo parameterSetInfo in command.ParameterSets)
135+
{
136+
if (parameterSetInfo.IsDefault)
137+
{
138+
defaultParameterSet = parameterSetInfo.Name;
139+
break;
140+
}
141+
}
142+
132143
commandList.Add(new PSCommandMessage
133144
{
134145
Name = command.Name,
135146
ModuleName = command.ModuleName,
136147
Parameters = command.Parameters,
137148
ParameterSets = command.ParameterSets,
138-
DefaultParameterSet = command.DefaultParameterSet
149+
DefaultParameterSet = defaultParameterSet
139150
});
140151
}
141152
}

src/PowerShellEditorServices/Services/PowerShellContext/Utilities/CommandHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
4545
Validate.IsNotNull(nameof(commandName), commandName);
4646
Validate.IsNotNull(nameof(powerShellContext), powerShellContext);
4747

48-
// Make sure the command's noun isn't blacklisted. This is
48+
// Make sure the command's noun isn't exclusion-listed. This is
4949
// currently necessary to make sure that Get-Command doesn't
5050
// load PackageManagement or PowerShellGet because they cause
5151
// a major slowdown in IntelliSense.

test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,8 @@ await LanguageClient.SendRequest<EvaluateResponseBody>(
970970
[Fact]
971971
public async Task CanSendGetCommandRequest()
972972
{
973-
List<PSCommandMessage> pSCommandMessages =
974-
await LanguageClient.SendRequest<List<PSCommandMessage>>("powerShell/getCommand", new GetCommandParams());
973+
List<object> pSCommandMessages =
974+
await LanguageClient.SendRequest<List<object>>("powerShell/getCommand", new GetCommandParams());
975975

976976
Assert.NotEmpty(pSCommandMessages);
977977
// There should be at least 20 commands or so.

0 commit comments

Comments
 (0)