Analyzes the solution on build in order to determine if it has SonarQube rulesets and log that using ITelemetryLogger.
상속: IDisposable
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                this.usageAnalyzer?.Dispose();
                this.usageAnalyzer = null;

                this.sonarAnalyzerManager?.Dispose();
                this.sonarAnalyzerManager = null;
            }
        }
        protected override void Initialize()
        {
            base.Initialize();
            this.InitializeSqm();

            IServiceProvider serviceProvider = this;

            this.sonarAnalyzerManager = new SonarAnalyzerManager(serviceProvider);
            this.usageAnalyzer = new BoundSolutionAnalyzer(serviceProvider);
            this.commandManager = new PackageCommandManager(serviceProvider);

            this.commandManager.Initialize();
        }
        public void BoundSolutionAnalyzer_HasNoRuleSetsInSonarQubeDirectory()
        {
            // Setup
            string sonarQubeDirectory = Path.Combine(this.solutionRootFolder, BoundSolutionAnalyzer.SonarQubeFilesFolder);
            DeleteBindingInformationFile(sonarQubeDirectory);
            using (var testSubject = new BoundSolutionAnalyzer(this.serviceProvider))
            {

                // Act
                this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, true);

                // Verify
                this.logger.AssertNoEventWasWritten();
            }
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                this.sonarAnalyzerManager?.Dispose();
                this.sonarAnalyzerManager = null;

                this.usageAnalyzer?.Dispose();
                this.usageAnalyzer = null;

                this.deprecationManager?.Dispose();
                this.deprecationManager = null;
            }
        }
        protected override void Initialize()
        {
            base.Initialize();
            this.InitializeSqm();

            IServiceProvider serviceProvider = this;

            this.sonarAnalyzerManager = new SonarAnalyzerManager(serviceProvider);
            this.suppressionManager   = new SuppressionManager(serviceProvider);
            this.usageAnalyzer        = new BoundSolutionAnalyzer(serviceProvider);

            this.commandManager = new PackageCommandManager(serviceProvider);
            this.commandManager.Initialize();

            this.deprecationManager = new DeprecationManager(this.GetMefService <IInfoBarManager>(),
                                                             this.GetMefService <ISonarLintOutput>());
            this.deprecationManager.Initialize(VisualStudioHelpers.VisualStudioVersion);
        }
        private async System.Threading.Tasks.Task InitOnUIThreadAsync()
        {
            Debug.Assert(ThreadHelper.CheckAccess(), "SonarLint package - expecteding to be called in the UI thread");

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

                Debug.Assert(logger != null, "MEF composition error - failed to retrieve a logger");
                logger.WriteLine(Resources.Strings.SL_Initializing);

                this.InitializeSqm();

                IServiceProvider serviceProvider = this;

                var activeSolutionBoundTracker = await this.GetMefServiceAsync <IActiveSolutionBoundTracker>();

                var sonarQubeService = await this.GetMefServiceAsync <ISonarQubeService>();

                var workspace = await this.GetMefServiceAsync <VisualStudioWorkspace>();


                var vsSolution = serviceProvider.GetService <SVsSolution, IVsSolution>();
                this.sonarAnalyzerManager = new SonarAnalyzerManager(activeSolutionBoundTracker, sonarQubeService, workspace,
                                                                     vsSolution, logger);

                this.usageAnalyzer = new BoundSolutionAnalyzer(serviceProvider);

                this.commandManager = new PackageCommandManager(serviceProvider.GetService <IMenuCommandService>());
                this.commandManager.Initialize(serviceProvider.GetMefService <ITeamExplorerController>(),
                                               serviceProvider.GetMefService <IProjectPropertyManager>());

                this.deprecationManager = new DeprecationManager(this.GetMefService <IInfoBarManager>(), logger);

                logger.WriteLine(Resources.Strings.SL_InitializationComplete);
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                // Suppress non-critical exceptions
                logger.WriteLine(Resources.Strings.SL_ERROR, ex.Message);
            }
        }
        public void BoundSolutionAnalyzer_HasRuleSetsInSonarQubeDirectory()
        {
            // Setup
            string sonarQubeDirectory = Path.Combine(this.solutionRootFolder, BoundSolutionAnalyzer.SonarQubeFilesFolder);
            GenerateBindingInformationFile(sonarQubeDirectory);
            BoundSolutionAnalyzer testSubject = null;

            try
            {
                // Case 1: Context is already active
                this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, true);

                // Act
                testSubject = new BoundSolutionAnalyzer(this.serviceProvider);

                // Verify
                this.logger.AssertSingleEventWasWritten(TelemetryEvent.BoundSolutionDetected);

                // Case 2: Context deactivated
                this.logger.Reset();

                // Act
                this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, false);

                // Verify
                this.logger.AssertNoEventWasWritten();

                // Case 3: Context activated
                this.logger.Reset();

                // Act
                this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, true);

                // Verify
                this.logger.AssertSingleEventWasWritten(TelemetryEvent.BoundSolutionDetected);

                // Case 4: reactivate when disposed
                this.logger.Reset();
                this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, false);
                testSubject.Dispose();
                testSubject = null;

                // Act
                this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, true);

                // Verify
                this.logger.AssertNoEventWasWritten();
            }
            finally
            {
                testSubject?.Dispose();
                DeleteBindingInformationFile(sonarQubeDirectory);
            }
        }