예제 #1
0
        private void AttachDebugger(int vsProcessId, int port, Version nodeVersion)
        {
#if !NETSTANDARD2_0
            try
            {
                if (nodeVersion >= Node8Version)
                {
                    VisualStudioApp.AttachToProcessNode2DebugAdapter(vsProcessId, port);
                }
                else
                {
                    //the '#ping=0' is a special flag to tell VS node debugger not to connect to the port,
                    //because a connection carries the consequence of setting off --debug-brk, and breakpoints will be missed.
                    var qualifierUri = string.Format("tcp://localhost:{0}#ping=0", port);
                    while (!VisualStudioApp.AttachToProcess(this.nodeProcess.Process, vsProcessId, NodejsRemoteDebugPortSupplierUnsecuredId, qualifierUri))
                    {
                        if (this.nodeProcess.Wait(TimeSpan.FromMilliseconds(500)))
                        {
                            break;
                        }
                    }
                }
#if DEBUG
            }
            catch (COMException ex)
            {
                this.frameworkHandle.SendMessage(TestMessageLevel.Error, "Error occurred connecting to debuggee.");
                this.frameworkHandle.SendMessage(TestMessageLevel.Error, ex.ToString());
                this.KillNodeProcess();
            }
#else
            }