Example #1
0
 /// <summary>
 /// Initializes a new instance of the EditorServicesHost class and waits for
 /// the debugger to attach if waitForDebugger is true.
 /// </summary>
 /// <param name="hostDetails">The details of the host which is launching PowerShell Editor Services.</param>
 /// <param name="bundledModulesPath">Provides a path to PowerShell modules bundled with the host, if any.  Null otherwise.</param>
 /// <param name="waitForDebugger">If true, causes the host to wait for the debugger to attach before proceeding.</param>
 /// <param name="additionalModules">Modules to be loaded when initializing the new runspace.</param>
 /// <param name="featureFlags">Features to enable for this instance.</param>
 public EditorServicesHost(
     HostDetails hostDetails,
     string bundledModulesPath,
     bool enableConsoleRepl,
     bool waitForDebugger,
     string[] additionalModules,
     string[] featureFlags)
     : this(
         hostDetails,
         bundledModulesPath,
         enableConsoleRepl,
         waitForDebugger,
         additionalModules,
         featureFlags,
         GetInternalHostFromDefaultRunspace())
 {
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the EditorServicesHost class and waits for
        /// the debugger to attach if waitForDebugger is true.
        /// </summary>
        /// <param name="hostDetails">The details of the host which is launching PowerShell Editor Services.</param>
        /// <param name="bundledModulesPath">Provides a path to PowerShell modules bundled with the host, if any.  Null otherwise.</param>
        /// <param name="waitForDebugger">If true, causes the host to wait for the debugger to attach before proceeding.</param>
        /// <param name="additionalModules">Modules to be loaded when initializing the new runspace.</param>
        /// <param name="featureFlags">Features to enable for this instance.</param>
        /// <param name="internalHost">The value of the $Host variable in the original runspace.</param>
        public EditorServicesHost(
            HostDetails hostDetails,
            string bundledModulesPath,
            bool enableConsoleRepl,
            bool waitForDebugger,
            string[] additionalModules,
            string[] featureFlags,
            PSHost internalHost)
        {
            Validate.IsNotNull(nameof(hostDetails), hostDetails);
            Validate.IsNotNull(nameof(internalHost), internalHost);

            _hostDetails = hostDetails;

            //this._hostDetails = hostDetails;
            _enableConsoleRepl = enableConsoleRepl;
            //this.bundledModulesPath = bundledModulesPath;
            _additionalModules = additionalModules ?? Array.Empty <string>();
            _featureFlags      = new HashSet <string>(featureFlags ?? Array.Empty <string>());
            //this.serverCompletedTask = new TaskCompletionSource<bool>();
            _internalHost = internalHost;

#if DEBUG
            if (waitForDebugger)
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Break();
                }
                else
                {
                    System.Diagnostics.Debugger.Launch();
                }
            }
#endif

            // Catch unhandled exceptions for logging purposes
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
        }