private async System.Threading.Tasks.Task InitAsync()
        {
            ILogger logger = null;

            try
            {
                logger = await this.GetMefServiceAsync <ILogger>();

                logger.WriteLine(Resources.Strings.Daemon_Initializing);

                daemon = await this.GetMefServiceAsync <ISonarLintDaemon>();

                var settings = await this.GetMefServiceAsync <ISonarLintSettings>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);

                if (daemon.IsInstalled)
                {
                    if (settings.IsActivateMoreEnabled && !daemon.IsRunning)
                    {
                        daemon.Start();
                    }
                }
                else
                {
                    if (settings.IsActivateMoreEnabled)
                    {
                        // User already agreed to have the daemon installed, so directly start download
                        await JoinableTaskFactory.SwitchToMainThreadAsync();

                        new SonarLintDaemonInstaller(settings, daemon, logger).Show();
                    }
                    else if (!settings.SkipActivateMoreDialog)
                    {
                        await JoinableTaskFactory.SwitchToMainThreadAsync();

                        var result = new SonarLintDaemonSplashscreen(settings).ShowDialog();
                        if (result == true)
                        {
                            new SonarLintDaemonInstaller(settings, daemon, logger).Show();
                        }
                    }
                }
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger?.WriteLine(Resources.Strings.ERROR_InitializingDaemon, ex);
            }
            logger?.WriteLine(Resources.Strings.Daemon_InitializationComplete);
        }
        private async System.Threading.Tasks.Task InitAsync()
        {
            try
            {
                logger = await this.GetMefServiceAsync <ILogger>();

                logger.WriteLine(Resources.Strings.Daemon_Initializing);

                await DisableRuleCommand.InitializeAsync(this, logger);

                await CFamilyReproducerCommand.InitializeAsync(this, logger);

                cFamilyPreCompiledHeadersEventListener = await this.GetMefServiceAsync <IPreCompiledHeadersEventListener>();

                daemon = await this.GetMefServiceAsync <ISonarLintDaemon>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);

                // Set up the solution tracker so we can shut down the daemon when a solution is closed
                var solutionTracker = await this.GetMefServiceAsync <IActiveSolutionTracker>();

                solutionTracker.ActiveSolutionChanged += HandleActiveSolutionChanged;

                IDaemonInstaller installer = await this.GetMefServiceAsync <IDaemonInstaller>();

                if (!installer.IsInstalled())
                {
                    // Set up the status bar download handler in case the user enables
                    // support for additional languages during the VS session
                    var sbService = await this.GetServiceAsync(typeof(IVsStatusbar)) as IVsStatusbar;

                    statusBarDownloadProgressHandler = new StatusBarDownloadProgressHandler(sbService, installer, logger);

                    var settings = await this.GetMefServiceAsync <ISonarLintSettings>();

                    if (settings.IsActivateMoreEnabled)
                    {
                        // User already agreed to have the daemon installed so directly start download.
                        // No UI interation so we don't need to be on the UI thread.
                        installer.Install();
                    }
                }
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger?.WriteLine(Resources.Strings.ERROR_InitializingDaemon, ex);
            }
            logger?.WriteLine(Resources.Strings.Daemon_InitializationComplete);
        }
Пример #3
0
        private async System.Threading.Tasks.Task Init()
        {
            try
            {
                this.daemon = await this.GetMefServiceAsync <ISonarLintDaemon>();

                var settings = await this.GetMefServiceAsync <ISonarLintSettings>();

                var logger = await this.GetMefServiceAsync <ILogger>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);

                if (settings.IsActivateMoreEnabled && daemon.IsInstalled)
                {
                    if (!daemon.IsRunning)
                    {
                        daemon.Start();
                    }
                }
                else if (settings.IsActivateMoreEnabled)
                {
                    // User already agreed to have the daemon installed, so directly start download
                    await JoinableTaskFactory.SwitchToMainThreadAsync();

                    new SonarLintDaemonInstaller(settings, daemon).Show();
                }
                else if (!settings.SkipActivateMoreDialog)
                {
                    await JoinableTaskFactory.SwitchToMainThreadAsync();

                    var result = new SonarLintDaemonSplashscreen(settings).ShowDialog();
                    if (result == true)
                    {
                        new SonarLintDaemonInstaller(settings, daemon).Show();
                    }
                }
            }
            catch (Exception)
            {
                // Log this
            }
        }
        private async System.Threading.Tasks.Task InitAsync()
        {
            try
            {
                logger = await this.GetMefServiceAsync <ILogger>();

                logger.WriteLine(Resources.Strings.Daemon_Initializing);

                await DisableRuleCommand.InitializeAsync(this, logger);

                await CFamilyReproducerCommand.InitializeAsync(this, logger);

                cFamilyPreCompiledHeadersEventListener = await this.GetMefServiceAsync <IPreCompiledHeadersEventListener>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger?.WriteLine(Resources.Strings.ERROR_InitializingDaemon, ex);
            }
            logger?.WriteLine(Resources.Strings.Daemon_InitializationComplete);
        }