diff --git a/module/PowerShellEditorServices/PowerShellEditorServices.psd1 b/module/PowerShellEditorServices/PowerShellEditorServices.psd1
index 77772c481..4c5887f4f 100644
--- a/module/PowerShellEditorServices/PowerShellEditorServices.psd1
+++ b/module/PowerShellEditorServices/PowerShellEditorServices.psd1
@@ -76,11 +76,7 @@ Copyright = '(c) 2017 Microsoft. All rights reserved.'
FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-CmdletsToExport = @(
- 'Start-EditorServices',
- '__Invoke-ReadLineForEditorServices',
- '__Invoke-ReadLineConstructor'
-)
+CmdletsToExport = @('Start-EditorServices')
# Variables to export from this module
VariablesToExport = @()
diff --git a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs
index 48d28d16d..d27708c39 100644
--- a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs
+++ b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs
@@ -12,7 +12,6 @@ namespace Microsoft.PowerShell.EditorServices.Commands
///
/// The Start-EditorServices command, the conventional entrypoint for PowerShell Editor Services.
///
- [Cmdlet("__Invoke", "ReadLineConstructor")]
public sealed class InvokeReadLineConstructorCommand : PSCmdlet
{
protected override void EndProcessing()
diff --git a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs
index 7590f769d..20aa66d44 100644
--- a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs
+++ b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs
@@ -14,7 +14,6 @@ namespace Microsoft.PowerShell.EditorServices.Commands
///
/// The Start-EditorServices command, the conventional entrypoint for PowerShell Editor Services.
///
- [Cmdlet("__Invoke", "ReadLineForEditorServices")]
public sealed class InvokeReadLineForEditorServicesCommand : PSCmdlet
{
private delegate string ReadLineInvoker(
diff --git a/src/PowerShellEditorServices/Server/PsesDebugServer.cs b/src/PowerShellEditorServices/Server/PsesDebugServer.cs
index 73b20546b..3e74221a5 100644
--- a/src/PowerShellEditorServices/Server/PsesDebugServer.cs
+++ b/src/PowerShellEditorServices/Server/PsesDebugServer.cs
@@ -12,6 +12,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.PowerShell.EditorServices.Handlers;
using Microsoft.PowerShell.EditorServices.Services;
+using Microsoft.PowerShell.EditorServices.Utility;
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.LanguageServer.Server;
@@ -28,6 +29,12 @@ internal class PsesDebugServer : IDisposable
///
private static int s_hasRunPsrlStaticCtor = 0;
+ private static readonly Lazy s_lazyInvokeReadLineConstructorCmdletInfo = new Lazy(() =>
+ {
+ var type = Type.GetType("Microsoft.PowerShell.EditorServices.Commands.InvokeReadLineConstructorCommand, Microsoft.PowerShell.EditorServices.Hosting");
+ return new CmdletInfo("__Invoke-ReadLineConstructor", type);
+ });
+
private readonly Stream _inputStream;
private readonly Stream _outputStream;
private readonly bool _useTempSession;
@@ -80,8 +87,10 @@ public async Task StartAsync()
// This is only needed for Temp sessions who only have a debug server.
if (_usePSReadLine && _useTempSession && Interlocked.Exchange(ref s_hasRunPsrlStaticCtor, 1) == 0)
{
+ var command = new PSCommand()
+ .AddCommand(s_lazyInvokeReadLineConstructorCmdletInfo.Value);
+
// This must be run synchronously to ensure debugging works
- var command = new PSCommand().AddCommand("__Invoke-ReadLineConstructor");
_powerShellContextService
.ExecuteCommandAsync