static void Main(string[] args)
        {
#if DEBUG
            // In the future, a more robust argument parser will be added here
            bool waitForDebugger =
                args.Any(
                    arg =>
                    string.Equals(
                        arg,
                        "/waitForDebugger",
                        StringComparison.InvariantCultureIgnoreCase));

            // Should we wait for the debugger before starting?
            if (waitForDebugger)
            {
                // Wait for 15 seconds and then continue
                int waitCountdown = 15;
                while (!Debugger.IsAttached && waitCountdown > 0)
                {
                    Thread.Sleep(1000);
                    waitCountdown--;
                }
            }
#endif

            bool runDebugAdapter =
                args.Any(
                    arg =>
                    string.Equals(
                        arg,
                        "/debugAdapter",
                        StringComparison.InvariantCultureIgnoreCase));

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

            if (runDebugAdapter)
            {
                // TODO: Remove this behavior in the near future --
                //   Create the debug service log in a separate file
                //   so that there isn't a conflict with the default
                //   log file.
                Logger.Initialize("DebugAdapter.log", LogLevel.Verbose);
            }
            else
            {
                // Initialize the logger
                // TODO: Set the level based on command line parameter
                Logger.Initialize(minimumLogLevel: LogLevel.Verbose);
            }

            Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host started!");

            MessageLoop messageLoop = new MessageLoop(runDebugAdapter);
            messageLoop.Start();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            #if DEBUG
            // In the future, a more robust argument parser will be added here
            bool waitForDebugger =
                args.Any(
                    arg =>
                        string.Equals(
                            arg,
                            "/waitForDebugger",
                            StringComparison.InvariantCultureIgnoreCase));

            // Should we wait for the debugger before starting?
            if (waitForDebugger)
            {
                // Wait for 15 seconds and then continue
                int waitCountdown = 15;
                while (!Debugger.IsAttached && waitCountdown > 0)
                {
                    Thread.Sleep(1000);
                    waitCountdown--;
                }
            }
            #endif

            bool runDebugAdapter =
                args.Any(
                    arg =>
                        string.Equals(
                            arg,
                            "/debugAdapter",
                            StringComparison.InvariantCultureIgnoreCase));

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

            if (runDebugAdapter)
            {
                // TODO: Remove this behavior in the near future --
                //   Create the debug service log in a separate file
                //   so that there isn't a conflict with the default
                //   log file.
                Logger.Initialize("DebugAdapter.log", LogLevel.Verbose);
            }
            else
            {
                // Initialize the logger
                // TODO: Set the level based on command line parameter
                Logger.Initialize(minimumLogLevel: LogLevel.Verbose);
            }

            Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host started!");

            MessageLoop messageLoop = new MessageLoop(runDebugAdapter);
            messageLoop.Start();
        }