コード例 #1
0
        private async Task <bool> DownloadTypings(IEnumerable <string> packages, Redirector redirector)
        {
            if (!packages.Any())
            {
                return(true);
            }

            string tsdPath = await EnsureTsdInstalled();

            if (string.IsNullOrEmpty(tsdPath))
            {
                if (redirector != null)
                {
                    redirector.WriteErrorLine(SR.GetString(SR.TsdNotInstalledError));
                }
                return(false);
            }

            using (var process = ProcessOutput.Run(
                       tsdPath,
                       TsdInstallArguments(packages),
                       _pathToRootProjectDirectory,
                       null,
                       false,
                       redirector,
                       quoteArgs: true)) {
                if (!process.IsStarted)
                {
                    // Process failed to start, and any exception message has
                    // already been sent through the redirector
                    if (redirector != null)
                    {
                        redirector.WriteErrorLine("could not start tsd");
                    }
                    return(false);
                }
                var i = await process;
                if (i == 0)
                {
                    if (redirector != null)
                    {
                        redirector.WriteLine(SR.GetString(SR.TsdInstallCompleted));
                    }
                    return(true);
                }
                else
                {
                    process.Kill();
                    if (redirector != null)
                    {
                        redirector.WriteErrorLine(SR.GetString(SR.TsdInstallErrorOccurred));
                    }
                    return(false);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles disconnect from debugger.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event arguments.</param>
        private void OnConnectionClosed(object sender, EventArgs e)
        {
            ConcurrentDictionary <int, TaskCompletionSource <JObject> > messages = Interlocked.Exchange(ref _messages, new ConcurrentDictionary <int, TaskCompletionSource <JObject> >());

            foreach (var kv in messages)
            {
                var exception = new IOException(SR.GetString(SR.DebuggerConnectionClosed));
                kv.Value.SetException(exception);
            }

            messages.Clear();
        }
コード例 #3
0
        private async Task <string> EnsureTypingsToolInstalled(Redirector redirector)
        {
            if (File.Exists(TypingsToolPath))
            {
                return(TypingsToolPath);
            }

            if (_didTryToInstallTypingsTool)
            {
                return(null);
            }
            if (!await InstallTypingsTool())
            {
                redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolInstallFailed));
                return(null);
            }
            return(await EnsureTypingsToolInstalled(redirector));
        }
コード例 #4
0
        private async Task <bool> ExecuteTypingsTool(IEnumerable <string> arguments, Redirector redirector)
        {
            string typingsTool = await EnsureTypingsToolInstalled(redirector);

            if (string.IsNullOrEmpty(typingsTool))
            {
                redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolNotInstalledError));
                return(false);
            }

            using (var process = ProcessOutput.Run(
                       typingsTool,
                       arguments,
                       _pathToRootProjectDirectory,
                       null,
                       false,
                       redirector,
                       quoteArgs: true,
                       outputEncoding: Encoding.UTF8,
                       errorEncoding: Encoding.UTF8)) {
                if (!process.IsStarted)
                {
                    // Process failed to start, and any exception message has
                    // already been sent through the redirector
                    redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolCouldNotStart));
                    return(false);
                }
                var i = await process;
                if (i == 0)
                {
                    redirector?.WriteLine(SR.GetString(SR.TypingsToolTypingsInstallCompleted));
                    return(true);
                }
                else
                {
                    process.Kill();
                    redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolTypingsInstallErrorOccurred));
                    return(false);
                }
            }
        }