From 7870ad790cd9434ec8e9ac1f7735ef303b0b21eb Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh <117642191+georgii-borovinskikh-sonarsource@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:40:23 +0100 Subject: [PATCH] Change ProjectRootCalculator to use IActiveSolutionBoundTracker (#5071) Fixes #5070 --- .../ProjectRootCalculatorTests.cs | 10 +++++----- src/ConnectedMode/ProjectRootCalculator.cs | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ConnectedMode.UnitTests/ProjectRootCalculatorTests.cs b/src/ConnectedMode.UnitTests/ProjectRootCalculatorTests.cs index acf9cd729..e936dd290 100644 --- a/src/ConnectedMode.UnitTests/ProjectRootCalculatorTests.cs +++ b/src/ConnectedMode.UnitTests/ProjectRootCalculatorTests.cs @@ -35,7 +35,7 @@ public void MefCtor_CheckIsExported() { MefTestHelpers.CheckTypeCanBeImported( MefTestHelpers.CreateExport(), - MefTestHelpers.CreateExport(), + MefTestHelpers.CreateExport(), MefTestHelpers.CreateExport()); } @@ -49,7 +49,7 @@ public void MefCtor_CheckIsSingleton() public async Task CalculateBasedOnLocalPathAsync_StandaloneMode_ReturnsNull() { var testSubject = CreateTestSubject(out _, out var configurationProviderMock, out _); - configurationProviderMock.Setup(x => x.GetConfiguration()).Returns(BindingConfiguration.Standalone); + configurationProviderMock.SetupGet(x => x.CurrentConfiguration).Returns(BindingConfiguration.Standalone); var result = await testSubject.CalculateBasedOnLocalPathAsync(@"c:\somepath", CancellationToken.None); @@ -64,7 +64,7 @@ public async Task CalculateBasedOnLocalPathAsync_ConnectedMode_ReturnsCorrectRoo var testSubject = CreateTestSubject(out var sonarQubeServiceMock, out var configurationProviderMock, out var branchProviderMock); configurationProviderMock - .Setup(x => x.GetConfiguration()) + .SetupGet(x => x.CurrentConfiguration) .Returns(BindingConfiguration.CreateBoundConfiguration( new BoundSonarQubeProject(){ProjectKey = projectKey}, SonarLintMode.Connected, @@ -82,11 +82,11 @@ public async Task CalculateBasedOnLocalPathAsync_ConnectedMode_ReturnsCorrectRoo } private ProjectRootCalculator CreateTestSubject(out Mock sonarQubeServiceMock, - out Mock configurationProviderMock, + out Mock activeSolutionBoundTracker, out Mock statefulServerBranchProviderMock) { return new ProjectRootCalculator((sonarQubeServiceMock = new Mock(MockBehavior.Strict)).Object, - (configurationProviderMock = new Mock(MockBehavior.Strict)).Object, + (activeSolutionBoundTracker = new Mock(MockBehavior.Strict)).Object, (statefulServerBranchProviderMock = new Mock(MockBehavior.Strict)).Object); } } diff --git a/src/ConnectedMode/ProjectRootCalculator.cs b/src/ConnectedMode/ProjectRootCalculator.cs index 63a11710a..5258432bf 100644 --- a/src/ConnectedMode/ProjectRootCalculator.cs +++ b/src/ConnectedMode/ProjectRootCalculator.cs @@ -39,20 +39,20 @@ internal interface IProjectRootCalculator internal class ProjectRootCalculator : IProjectRootCalculator { private readonly ISonarQubeService sonarQubeService; - private readonly IConfigurationProvider configurationProvider; + private readonly IActiveSolutionBoundTracker activeSolutionBoundTracker; private readonly IStatefulServerBranchProvider branchProvider; [ImportingConstructor] - public ProjectRootCalculator(ISonarQubeService sonarQubeService, IConfigurationProvider configurationProvider, IStatefulServerBranchProvider branchProvider) + public ProjectRootCalculator(ISonarQubeService sonarQubeService, IActiveSolutionBoundTracker activeSolutionBoundTracker, IStatefulServerBranchProvider branchProvider) { this.sonarQubeService = sonarQubeService; - this.configurationProvider = configurationProvider; + this.activeSolutionBoundTracker = activeSolutionBoundTracker; this.branchProvider = branchProvider; } public async Task CalculateBasedOnLocalPathAsync(string localPath, CancellationToken token) { - var bindingConfiguration = configurationProvider.GetConfiguration(); + var bindingConfiguration = activeSolutionBoundTracker.CurrentConfiguration; if (bindingConfiguration.Mode == SonarLintMode.Standalone) {