PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

Find a way to bring back AstVisitor2 usage

Open daviwil opened this issue 9 years ago • 4 comments

After the recent design of the PSES host to be loaded as a module inside of powershell.exe, it appears that one of our multi-version PowerShell support tricks don't work any longer. When a user running PSv3 or PSv4 loads up Microsoft.PowerShell.EditorServices.dll it crashes due to the use of AstVisitor2 in the FindSymbolsVisitor2 class. For now I'm just going to comment out this class so that I can get a fix out for those impacted by the 0.7.0 release.

In the near future we may have to split out features that only work in specific PS versions into separate DLLs that are loaded and registered dynamically depending on the PS version present.

daviwil avatar Aug 23 '16 20:08 daviwil

I was looking at adding support for class and enum symbols but it requires AstVisitor2. I ran across your comment in the commented out FindSymbolsVisitor2 class.

    // TODO: Restore this when we figure out how to support multiple
    //       PS versions in the new PSES-as-a-module world (issue #276)

If we are already selectively loaded assemblies based on the platform e.g.:

if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") {
    Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.dll"
    Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.Host.dll"
}
else {
    Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.dll"
    Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Host.dll"
}

Why not continue to build different assemblies for v3, v4 and v5 and load those depending on the PSVersion?

rkeithhill avatar Feb 21 '17 01:02 rkeithhill

That's what I'll end up doing. I'm going to be doing a big refactoring of the PSES codebase once I get 0.10.0 out, part of that will be restructuring the assemblies to enable some version-specific features without causing the assembly loader to throw exceptions.

daviwil avatar Feb 21 '17 14:02 daviwil

Looks like this one might be bundled into the whole "support for v3 and v4 or not" debate.

TylerLeonhardt avatar Jan 16 '18 19:01 TylerLeonhardt

Fixed by powershell/vscode-powershell#1310, right? Will move 4 of 6 visitors to AstVisitor2 in #1886

fflaten avatar Aug 15 '22 16:08 fflaten

@andschwa Ready to close

fflaten avatar Feb 07 '23 18:02 fflaten