PowerShellEditorServices
PowerShellEditorServices copied to clipboard
Enable Windows Arm64
PR Summary
- Make LoadAssemblyInPsesLoadContext an Instance method instead of static to fix a crash on windows arm64.
- Add .vs directory to git ignore.
- I realize this repo is primarily related to vscode, but I did open the solution in visual studio and wanted to ensure I didnt accidentally commit my state files.
- Remove unnecessary extra word in extension comment.
PR Context
I am experiencing crashes in the PSES internal host on Windows 11 arm64 (the qualcomm devkit). Here is an error log captured while print debugging showing the error:
2025-06-29 03:10:30.862 [info] Visual Studio Code: v1.102.0-insider 64-bit on Windows 64-bit
2025-06-29 03:10:30.862 [info] PowerShell Extension: v2025.3.1
2025-06-29 03:10:30.862 [info] Starting 'PowerShell (x64)' at: C:\Program Files (Arm)\PowerShell\7\pwsh.exe
2025-06-29 03:10:31.376 [info] PowerShell process started with PID: 26092
2025-06-29 03:10:35.772 [info] [PSES] Trace: OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request initialize 0 - System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Method invocation failed because [Microsoft.PowerShell.EditorServices.Extensions.Services.EditorExtensionServiceProvider] does not contain a method named 'LoadAssemblyInPsesLoadContext'.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear(PowerShell pwsh, PSInvocationSettings invocationSettings) in C:\Users\tmarvin\OneDrive\Development\Working\tmp\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 88
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeCommand(PowerShell pwsh, PSCommand psCommand, PSInvocationSettings invocationSettings) in C:\Users\tmarvin\OneDrive\Development\Working\tmp\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 105
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.LoadProfiles(PowerShell pwsh, ProfilePathInfo profilePaths) in C:\Users\tmarvin\OneDrive\Development\Working\tmp\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 219
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.<LoadHostProfilesAsync>b__113_0(PowerShell pwsh, CancellationToken _) in C:\Users\tmarvin\OneDrive\Development\Working\tmp\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 592
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPSDelegateTask.Run(CancellationToken cancellationToken) in C:\Users\tmarvin\OneDrive\Development\Working\tmp\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousDelegateTask.cs:line 95
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteSynchronously(CancellationToken executorCancellationToken) in C:\Users\tmarvin\OneDrive\Development\Working\tmp\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 92
--- End of stack trace from previous location ---
at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.TryStartAsync(HostStartOptions startOptions, CancellationToken cancellationToken) in C:\Users\tmarvin\OneDrive\Development\Working\tmp\PowerShellEditorServices\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 312
at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle(InternalInitializeParams request, CancellationToken token)
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() | Method='initialize' RequestId='0'
2025-06-29 03:10:35.773 [info] [PSES] Trace: OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError | @Request='OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError'
I looked through the codebase but unfortunately I wasn't able to figure out where this specific method instance was being accessed from in order to have it search for the static method.
This, along with this pr, resolves the issues I'm experiencing and enables me to use the PowerShell extension for code formatting.