Skip to content

Commit 23fa4bf

Browse files
authored
In PSCore RemoteSessionStateProxy.InvokeCommand throws PSNotImpemente… (#576)
* In PSCore RemoteSessionStateProxy.InvokeCommand throws PSNotImpementedException Fixes #1091 - I think. Well, at least the initial layer of the onion. Not sure what else we'll run into connecting to PS Core as the remote. I don't have a setup for testing that atm. Probably don't want to crash the extension if we can get aliases when the remote is PS Core. See https://github.com/PowerShell/PowerShell/blob/4bc52d2358222084738157a08907fac32d13bd3a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs#L2982-L2988 * Set areAliasesLoaded to true to prevent more calls to GetAliases Do this when we receive a PSNotSupportedException trying to get aliases from the (remote) session.
1 parent e19ab6f commit 23fa4bf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/PowerShellEditorServices/Language/LanguageService.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Microsoft.PowerShell.EditorServices.Symbols;
77
using Microsoft.PowerShell.EditorServices.Utility;
88
using System;
9-
using System.Collections;
109
using System.Collections.Generic;
1110
using System.Collections.Specialized;
1211
using System.Linq;
@@ -699,6 +698,15 @@ await this.powerShellContext.GetRunspaceHandle(
699698

700699
this.areAliasesLoaded = true;
701700
}
701+
catch (PSNotSupportedException e)
702+
{
703+
this.logger.Write(
704+
LogLevel.Warning,
705+
$"Caught PSNotSupportedException while attempting to get aliases from remote session:\n\n{e.ToString()}");
706+
707+
// Prevent the aliases from being fetched again - no point if the remote doesn't support InvokeCommand.
708+
this.areAliasesLoaded = true;
709+
}
702710
catch (TaskCanceledException)
703711
{
704712
// The wait for a RunspaceHandle has timed out, skip aliases for now

0 commit comments

Comments
 (0)