Skip to content

Commit

Permalink
SLVS-1492 Update SLCore to 10.7.1.79146 (#5731)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnaskos-sonar committed Oct 9, 2024
1 parent 9e7a3b4 commit 0ef7e0f
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/EmbeddedSonarAnalyzer.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<EmbeddedSonarJSAnalyzerVersion>10.14.0.26080</EmbeddedSonarJSAnalyzerVersion>
<EmbeddedSonarSecretsJarVersion>2.15.0.3845</EmbeddedSonarSecretsJarVersion>
<!-- SLOOP: Binaries for SonarLint Out Of Process -->
<EmbeddedSloopVersion>10.6.0.79033</EmbeddedSloopVersion>
<EmbeddedSloopVersion>10.7.1.79146</EmbeddedSloopVersion>
</PropertyGroup>
</Project>
12 changes: 10 additions & 2 deletions src/SLCore.Listeners.UnitTests/BranchListenerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using System.Collections.Generic;
using System.Threading.Tasks;
using SonarLint.VisualStudio.SLCore.Core;
using SonarLint.VisualStudio.SLCore.Listener.Branch;

Expand Down Expand Up @@ -66,5 +64,15 @@ public void DidChangeMatchedSonarProjectBranch_ReturnsTaskCompleted(object param

result.Should().Be(Task.CompletedTask);
}

[TestMethod]
public async Task MatchProjectBranchAsync_ReturnsAlwaysTrue()
{
var testSubject = new BranchListener();

var response = await testSubject.MatchProjectBranchAsync(new MatchProjectBranchParams("my_config_scope_id", "the_branch_name"));

response.Should().BeEquivalentTo(new MatchProjectBranchResponse(true));
}
}
}
11 changes: 9 additions & 2 deletions src/SLCore.Listeners/Implementation/BranchListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using SonarLint.VisualStudio.SLCore.Core;
using SonarLint.VisualStudio.SLCore.Listener.Branch;

Expand Down Expand Up @@ -49,5 +47,14 @@ public Task DidChangeMatchedSonarProjectBranchAsync(object parameters)
{
return Task.CompletedTask;
}

public Task<MatchProjectBranchResponse> MatchProjectBranchAsync(MatchProjectBranchParams parameters)
{
// At the moment we don't need to match the project branch as there is logic to handle the cases
// where there is a mismatch between the project branch and the server branch
// This is currently not fully supported because it depends on the showMessage method
// https://sonarsource.atlassian.net/browse/SLVS-1494
return Task.FromResult(new MatchProjectBranchResponse(true));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using Newtonsoft.Json;
using SonarLint.VisualStudio.SLCore.Listener.Branch;

namespace SonarLint.VisualStudio.SLCore.UnitTests.Listener.Branch;

[TestClass]
public class MatchProjectBranchParamsTests
{
[TestMethod]
public void Deserialize_AsExpected()
{
var expectedObject = new MatchProjectBranchParams("CONFIG_SCOPE_ID", "remote-branch-name");

const string serializedParams = """
{
"configurationScopeId": "CONFIG_SCOPE_ID",
"serverBranchToMatch": "remote-branch-name"
}
""";

var deserializedObject = JsonConvert.DeserializeObject<MatchProjectBranchParams>(serializedParams);

deserializedObject.Should().Be(expectedObject);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using Newtonsoft.Json;
using SonarLint.VisualStudio.SLCore.Listener.Branch;

namespace SonarLint.VisualStudio.SLCore.UnitTests.Listener.Branch;

[TestClass]
public class MatchProjectBranchResponseTests
{
[TestMethod]
[DataRow(true, "true")]
[DataRow(false, "false")]
public void Serialize_AsExpected(bool isBranchMatched, string expectedResponse)
{
var testSubject = new MatchProjectBranchResponse(isBranchMatched);

var expectedString = $$"""
{
"isBranchMatched": {{expectedResponse}}
}
""";

var serializedString = JsonConvert.SerializeObject(testSubject, Formatting.Indented);

serializedString.Should().Be(expectedString);
}
}
9 changes: 8 additions & 1 deletion src/SLCore/Listener/Branch/IBranchListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using System.Threading.Tasks;
using SonarLint.VisualStudio.SLCore.Core;

namespace SonarLint.VisualStudio.SLCore.Listener.Branch;
Expand All @@ -38,4 +37,12 @@ public interface IBranchListener : ISLCoreListener
/// <param name="parameters">Parameter's here for compability we discard it</param>
/// <remarks>This will be implemented properly in the future when needed but features we support does not need branch awareness for now</remarks>
Task DidChangeMatchedSonarProjectBranchAsync(object parameters);

/// <summary>
/// Used for checking whether a locally checked out branch matches a candidate branch name (not necessarily a Sonar branch).
/// For example, in "show fix suggestion" use-case, to match a local branch with a PR branch that originated a fix suggestion
/// </summary>
/// <param name="parameters">The remote branch details to match</param>
/// <returns>Is local branch matching the remote branch</returns>
Task<MatchProjectBranchResponse> MatchProjectBranchAsync(MatchProjectBranchParams parameters);
}
23 changes: 23 additions & 0 deletions src/SLCore/Listener/Branch/MatchProjectBranchParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

namespace SonarLint.VisualStudio.SLCore.Listener.Branch;

public record MatchProjectBranchParams(string configurationScopeId, string serverBranchToMatch);
23 changes: 23 additions & 0 deletions src/SLCore/Listener/Branch/MatchProjectBranchResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

namespace SonarLint.VisualStudio.SLCore.Listener.Branch;

public record MatchProjectBranchResponse(bool isBranchMatched);

0 comments on commit 0ef7e0f

Please sign in to comment.