From eee564e46509160f0e2d888659f0eb6b744f4af3 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 9 May 2016 16:34:16 -0700 Subject: [PATCH] Delete deprecated CoreConsoleHost project --- .../AssemblyInfo.cs | 8 - .../README.md | 25 - .../host.cs | 218 ---- .../main.cs | 857 ------------- .../project.json | 46 - .../rawui.cs | 237 ---- .../readline.cs | 1133 ----------------- .../ui.cs | 566 -------- 8 files changed, 3090 deletions(-) delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/AssemblyInfo.cs delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/README.md delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/host.cs delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/main.cs delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/project.json delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/rawui.cs delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/readline.cs delete mode 100644 src/Microsoft.PowerShell.CoreConsoleHost/ui.cs diff --git a/src/Microsoft.PowerShell.CoreConsoleHost/AssemblyInfo.cs b/src/Microsoft.PowerShell.CoreConsoleHost/AssemblyInfo.cs deleted file mode 100644 index 3e4b06af93..0000000000 --- a/src/Microsoft.PowerShell.CoreConsoleHost/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Reflection; -using System.Resources; - -[assembly:InternalsVisibleTo("powershell-tests")] - -[assembly:AssemblyCulture("")] -[assembly:NeutralResourcesLanguage("en-US")] diff --git a/src/Microsoft.PowerShell.CoreConsoleHost/README.md b/src/Microsoft.PowerShell.CoreConsoleHost/README.md deleted file mode 100644 index 9c8e1e197a..0000000000 --- a/src/Microsoft.PowerShell.CoreConsoleHost/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Core PowerShell Host - -This host is based off the infamous `host06` example. It relies only on managed -code, and is cross-platform. It needs a fair bit of work, but it loads -profiles, has tab-completion, and can be used to debug PowerShell scripts. - -## Executable - -The `bin/powershell[.exe]` executable for Core PowerShell is built by this -project, as it is the top dependency of the graph, and has `emitEntryPoint: -true`, meaning a native executable is produced automatically by CLI (no need to -own a separate native host). It is also the project that deploys the `ps1xml` -types and formatting files, as well as the default profile and the included -PowerShell modules. - -Note that many of these should probably live with System.Management.Automation, -but we're waiting on a bug fix from CLI to move them. - -## update-content.sh - -This script is used to update our current tree's files with those that live in -`src/monad`. We only need to update them when new changes are merged from -Source Depot, and the build scripts are much simpler without this logic. With -the files living here, the `content` key in the `project.json` handles the -deployment for us in a cross-platform manner. diff --git a/src/Microsoft.PowerShell.CoreConsoleHost/host.cs b/src/Microsoft.PowerShell.CoreConsoleHost/host.cs deleted file mode 100644 index c987abac76..0000000000 --- a/src/Microsoft.PowerShell.CoreConsoleHost/host.cs +++ /dev/null @@ -1,218 +0,0 @@ -namespace Microsoft.PowerShell.CoreConsoleHost -{ - using System; - using System.Globalization; - using System.Management.Automation.Host; - using System.Management.Automation.Runspaces; - - /// - /// This is a sample implementation of the PSHost abstract class for - /// console applications. Not all members are implemented. Those that - /// are not implemented throw a NotImplementedException exception or - /// return nothing. - /// - internal class MyHost : PSHost, IHostSupportsInteractiveSession - { - public MyHost(Listener Listener) - { - this.Listener = Listener; - this.myHostUserInterface = new MyHostUserInterface(Listener.HasUI, Listener.Interactive); - } - - /// - /// A reference to the PSHost implementation. - /// - private Listener Listener; - - /// - /// The culture information of the thread that created - /// this object. - /// - private CultureInfo originalCultureInfo = CultureInfo.CurrentCulture; - - /// - /// The UI culture information of the thread that created - /// this object. - /// - private CultureInfo originalUICultureInfo = CultureInfo.CurrentCulture; - - /// - /// The identifier of this PSHost implementation. - /// - private static Guid instanceId = Guid.NewGuid(); - - /// - /// A reference to the implementation of the PSHostUserInterface - /// class for this application. - /// - private MyHostUserInterface myHostUserInterface; - - /// - /// A reference to the runspace used to start an interactive session. - /// - public Runspace pushedRunspace = null; - - - /// - /// Gets the culture information to use. This implementation - /// returns a snapshot of the culture information of the thread - /// that created this object. - /// - public override CultureInfo CurrentCulture - { - get { return this.originalCultureInfo; } - } - - /// - /// Gets the UI culture information to use. This implementation - /// returns a snapshot of the UI culture information of the thread - /// that created this object. - /// - public override CultureInfo CurrentUICulture - { - get { return this.originalUICultureInfo; } - } - - /// - /// Gets an identifier for this host. This implementation always - /// returns the GUID allocated at instantiation time. - /// - public override Guid InstanceId - { - get { return instanceId; } - } - - /// - /// Gets a string that contains the name of this host implementation. - /// Keep in mind that this string may be used by script writers to - /// identify when your host is being used. - /// - public override string Name - { - get { return "CoreConsoleHost"; } - } - - /// - /// Gets an instance of the implementation of the PSHostUserInterface - /// class for this application. This instance is allocated once at startup time - /// and returned every time thereafter. - /// - public override PSHostUserInterface UI - { - get { return this.myHostUserInterface; } - } - - /// - /// Gets the version object for this application. Typically this - /// should match the version resource in the application. - /// - public override Version Version - { - get { return new Version(1, 0, 0, 0); } - } - -#region IHostSupportsInteractiveSession Properties - - /// - /// Gets a value indicating whether a request - /// to open a PSSession has been made. - /// - public bool IsRunspacePushed - { - get { return this.pushedRunspace != null; } - } - - /// - /// Gets or sets the runspace used by the PSSession. - /// - public Runspace Runspace - { - get { return this.Listener.myRunSpace; } - internal set { this.Listener.myRunSpace = value; } - } -#endregion IHostSupportsInteractiveSession Properties - - /// - /// This API Instructs the host to interrupt the currently running - /// pipeline and start a new nested input loop. In this example this - /// functionality is not needed so the method throws a - /// NotImplementedException exception. - /// - public override void EnterNestedPrompt() - { - throw new NotImplementedException( - "The method or operation is not implemented."); - } - - /// - /// This API instructs the host to exit the currently running input loop. - /// In this example this functionality is not needed so the method - /// throws a NotImplementedException exception. - /// - public override void ExitNestedPrompt() - { - throw new NotImplementedException( - "The method or operation is not implemented."); - } - - /// - /// This API is called before an external application process is - /// started. Typically it is used to save state so that the parent - /// can restore state that has been modified by a child process (after - /// the child exits). In this example this functionality is not - /// needed so the method returns nothing. - /// - public override void NotifyBeginApplication() - { - return; - } - - /// - /// This API is called after an external application process finishes. - /// Typically it is used to restore state that a child process has - /// altered. In this example, this functionality is not needed so - /// the method returns nothing. - /// - public override void NotifyEndApplication() - { - return; - } - - /// - /// Indicate to the host application that exit has - /// been requested. Pass the exit code that the host - /// application should use when exiting the process. - /// - /// The exit code that the - /// host application should use. - public override void SetShouldExit(int exitCode) - { - this.Listener.ShouldExit = true; - this.Listener.ExitCode = exitCode; - } - -#region IHostSupportsInteractiveSession Methods - - /// - /// Requests to close a PSSession. - /// - public void PopRunspace() - { - Runspace = this.pushedRunspace; - this.pushedRunspace = null; - } - - /// - /// Requests to open a PSSession. - /// - /// Runspace to use. - public void PushRunspace(Runspace runspace) - { - this.pushedRunspace = Runspace; - Runspace = runspace; - } - -#endregion IHostSupportsInteractiveSession Methods - } -} - diff --git a/src/Microsoft.PowerShell.CoreConsoleHost/main.cs b/src/Microsoft.PowerShell.CoreConsoleHost/main.cs deleted file mode 100644 index 94c0df6c1d..0000000000 --- a/src/Microsoft.PowerShell.CoreConsoleHost/main.cs +++ /dev/null @@ -1,857 +0,0 @@ -namespace Microsoft.PowerShell.CoreConsoleHost -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Management.Automation; - using System.Management.Automation.Host; - using System.Management.Automation.Runspaces; - using System.Text; - using System.IO; - using System.Runtime.InteropServices; - using System.Linq; - using PowerShell = System.Management.Automation.PowerShell; - - public static class Program - { - private enum Options {Help, File, Command, NoProfile, NonInteractive, EncodedCommand, Invalid}; - private class CommandOptions - { - public Options opt; - public string optString; - - public CommandOptions(Options o, string s) - { - opt = o; - optString = s; - } - } - - private static CommandOptions[] commandOptions = new CommandOptions[] - { - new CommandOptions(Options.Help, "help"), - new CommandOptions(Options.Help, "?"), - new CommandOptions(Options.File, "file"), - new CommandOptions(Options.Command, "command"), - new CommandOptions(Options.NoProfile, "noprofile"), - new CommandOptions(Options.NonInteractive, "noninteractive"), - new CommandOptions(Options.EncodedCommand, "encodedcommand") - }; - - /// - /// Creates and initiates the listener instance. - /// - public static void Main(string[] args) - { - // Setup the Assembly Load Context, which Core PowerShell uses to - // analyze the libraries for types, functions, cmdlets, etc. and - // provide the ability to load assemblies by file path. Doing this - // here eliminates the need for a custom native host. - PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(string.Empty); - - - // Argument parsing - string initialScript = null; - bool loadProfiles = true; - bool interactive = true; - - if (args.Length > 0) - { - for (int i = 0; i < args.Length; ++i) - { - string arg = args[i]; - bool hasNext = (i+1) < args.Length; - string nextArg = hasNext ? args[i+1] : string.Empty; - - // options start with "-" or "--" - - string option; - if (arg.StartsWith("-")) - { - if (arg.StartsWith("--")) - { - option = arg.Remove(0, 2); - } - else - { - option = arg.Remove(0, 1); - } - - Options bestOption = FindOption(option); - - switch (bestOption) - { - case Options.Help: - Console.WriteLine(@" -usage: powershell[.exe] [ (--help | -h | -?) ] - [ (--file | -f) ] - [