From 16be2b87752342148851868cc30656f47c646863 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Tue, 26 Oct 2021 14:41:19 -0700 Subject: [PATCH] Remove defunct internal cmdlets --- .../InvokeReadLineConstructorCommand.cs | 21 -------- .../InvokeReadLineForEditorServicesCommand.cs | 53 ------------------- 2 files changed, 74 deletions(-) delete mode 100644 src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs delete mode 100644 src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs diff --git a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs deleted file mode 100644 index 58038d13e..000000000 --- a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using System; -using System.Management.Automation; -using System.Runtime.CompilerServices; - -namespace Microsoft.PowerShell.EditorServices.Commands -{ - /// - /// The Start-EditorServices command, the conventional entrypoint for PowerShell Editor Services. - /// - public sealed class InvokeReadLineConstructorCommand : PSCmdlet - { - protected override void EndProcessing() - { - Type type = Type.GetType("Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2"); - RuntimeHelpers.RunClassConstructor(type.TypeHandle); - } - } -} diff --git a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs deleted file mode 100644 index b0adf6fc8..000000000 --- a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using System; -using System.Management.Automation; -using System.Management.Automation.Runspaces; -using System.Reflection; -using System.Threading; - -namespace Microsoft.PowerShell.EditorServices.Commands -{ - /// - /// The Start-EditorServices command, the conventional entrypoint for PowerShell Editor Services. - /// - public sealed class InvokeReadLineForEditorServicesCommand : PSCmdlet - { - private delegate string ReadLineInvoker( - Runspace runspace, - EngineIntrinsics engineIntrinsics, - CancellationToken cancellationToken); - - private static Lazy s_readLine = new Lazy(() => - { - Type type = Type.GetType("Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2"); - MethodInfo method = type?.GetMethod( - "ReadLine", - new[] { typeof(Runspace), typeof(EngineIntrinsics), typeof(CancellationToken) }); - - // TODO: Handle method being null here. This shouldn't ever happen. - - return (ReadLineInvoker)method.CreateDelegate(typeof(ReadLineInvoker)); - }); - - /// - /// The ID to give to the host's profile. - /// - [Parameter(Mandatory = true)] - [ValidateNotNullOrEmpty] - public CancellationToken CancellationToken { get; set; } - - protected override void EndProcessing() - { - // This returns a string. - object result = s_readLine.Value( - Runspace.DefaultRunspace, - SessionState.PSVariable.Get("ExecutionContext").Value as EngineIntrinsics, - CancellationToken - ); - - WriteObject(result); - } - } -}