SonarLint.VisualStudio.Integration.Vsix.BoundSolutionAnalyzer.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
        public void Dispose()
        {
            // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
            Dispose(true);
        }
        #endregion

Same methods

BoundSolutionAnalyzer::Dispose ( bool disposing ) : void

Usage Example

        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);
            }
        }