Vscode-powershell: Register-EditorCommand fails due to ALC changes

Created on 25 Feb 2020  路  9Comments  路  Source: PowerShell/vscode-powershell

Issue Description

I am experiencing a problem with running the below code in the Integrated terminal.

Register-EditorCommand -Name 'RunFileInExternalWindow' -DisplayName 'Run current file in external window' -ScriptBlock { Start-Process pwsh '-File',$psEditor.GetEditorContext().CurrentFile.Path }

Creating as discussed with @SeeminglyScience .

Attached Logs\screenshot

image

Environment Information

Visual Studio Code

Visual Studio Code(Click to Expand)

| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.18363 |
| VSCode | 1.42.1|
| PowerShell Extension Version | 2020.2.0 |

PowerShell Information

PowerShell Information(Click to Expand)

|Name|Value|
|---|---|
|PSVersion|7.0.0-rc.3|
|PSEdition|Core|
|GitCommitId|7.0.0-rc.3|
|OS|Microsoft Windows 10.0.18363|
|Platform|Win32NT|
|PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0 6.1.0 6.2.0 7.0.0-rc.3|
|PSRemotingProtocolVersion|2.3|
|SerializationVersion|1.1.0.1|
|WSManStackVersion|3.0|

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)

|Extension|Author|Version|
|---|---|---|
|powershell-preview|ms-vscode|2020.2.0|
|remote-wsl|ms-vscode-remote|0.42.3|

Area-psEditor Issue-Bug

All 9 comments

I can repro this on macOS in PS7.

I can't repro this on macOS in PS6 though, which is interesting.

Import-EditorCommand has some too, may just want to do a sweep of all the ps1's

Oh... PowerShell can't resolve any types from PSES outside of the Microsoft.PowerShell.EditorServices.Hosting assembly.

This might not be new, wasn't there an issue about Import-EditorCommand already from around the time ALC changes were made?

But why would it work on 6.2?

馃し鈥嶁檪 differences in how ALC's work?

Ah, I had assumed that loading the PSES asm into the default ALC would work for PowerShell, but I seems that loading it in the resolve event doesn't make it appear in the default ALC's assembly list... It happens that the way PowerShell exposes types in 7 has changed since 6.2.

I'll see if I can find a way to attach the PSES assembly to the default ALC properly.

I'll see if I can find a way to attach the PSES assembly to the default ALC properly.

Turns out this isn't possible, from what I've tried.

Ideally we could spin this out into a new assembly which is internally enlightened through the various APIs, but I don't think we have time for that before the release given the other high-priority bugs we want to address.

This works if we fully-qualify the type names for now, so I'll do that. Later on I'd like to spin out a separate module for it all. That will be a breaking change, but we'll do it with consultation and in a way that minimises the exposure to PowerShell. Certainly all the commands will be the same (just not the types).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukegriffith picture lukegriffith  路  3Comments

nathan-alden-hp picture nathan-alden-hp  路  3Comments

daviwil picture daviwil  路  4Comments

guidooliveira picture guidooliveira  路  3Comments

borisimple picture borisimple  路  3Comments