-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SLVS-1632 Add the ISonarProjectBranchSlCoreService interface (#5835)
- Loading branch information
1 parent
9be04ab
commit b858e06
Showing
7 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/SLCore.UnitTests/Service/Branch/DidVcsRepositoryChangeParamsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.Service.Branch; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Branch; | ||
|
||
[TestClass] | ||
public class DidVcsRepositoryChangeParamsTests | ||
{ | ||
[TestMethod] | ||
public void Serialize_AsExpected() | ||
{ | ||
var testSubject = new DidVcsRepositoryChangeParams("CONFIG_SCOPE_ID"); | ||
|
||
const string expectedString = """ | ||
{ | ||
"configurationScopeId": "CONFIG_SCOPE_ID" | ||
} | ||
"""; | ||
|
||
var serializedString = JsonConvert.SerializeObject(testSubject, Formatting.Indented); | ||
|
||
serializedString.Should().Be(expectedString); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/SLCore.UnitTests/Service/Branch/GetMatchedSonarProjectBranchParamsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.Service.Branch; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Branch; | ||
|
||
[TestClass] | ||
public class GetMatchedSonarProjectBranchParamsTests | ||
{ | ||
[TestMethod] | ||
public void Serialize_AsExpected() | ||
{ | ||
var testSubject = new GetMatchedSonarProjectBranchParams("CONFIG_SCOPE_ID"); | ||
|
||
const string expectedString = """ | ||
{ | ||
"configurationScopeId": "CONFIG_SCOPE_ID" | ||
} | ||
"""; | ||
|
||
var serializedString = JsonConvert.SerializeObject(testSubject, Formatting.Indented); | ||
|
||
serializedString.Should().Be(expectedString); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/SLCore.UnitTests/Service/Branch/GetMatchedSonarProjectBranchResponseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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.Service.Branch; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Branch; | ||
|
||
[TestClass] | ||
public class GetMatchedSonarProjectBranchResponseTests | ||
{ | ||
[TestMethod] | ||
public void Deserialized_AsExpected_SmokeTest() | ||
{ | ||
const string serialized = """ | ||
{ | ||
"matchedSonarProjectBranch": "the-branch" | ||
} | ||
"""; | ||
|
||
var actual = JsonConvert.DeserializeObject<GetMatchedSonarProjectBranchResponse>(serialized); | ||
|
||
actual.matchedSonarProjectBranch.Should().Be("the-branch"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Service.Branch; | ||
|
||
public record DidVcsRepositoryChangeParams(string configurationScopeId); |
23 changes: 23 additions & 0 deletions
23
src/SLCore/Service/Branch/GetMatchedSonarProjectBranchParams.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Service.Branch; | ||
|
||
public record GetMatchedSonarProjectBranchParams(string configurationScopeId); |
23 changes: 23 additions & 0 deletions
23
src/SLCore/Service/Branch/GetMatchedSonarProjectBranchResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Service.Branch; | ||
|
||
public record GetMatchedSonarProjectBranchResponse(string matchedSonarProjectBranch); |
38 changes: 38 additions & 0 deletions
38
src/SLCore/Service/Branch/ISonarProjectBranchSlCoreService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 SonarLint.VisualStudio.SLCore.Protocol; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.Service.Branch; | ||
|
||
[JsonRpcClass("branch")] | ||
public interface ISonarProjectBranchSlCoreService | ||
{ | ||
/// <summary> | ||
/// Must be called when any change on the VCS might lead to a different sonar project branch being resolved (could be a different HEAD, a branch checkout). | ||
/// </summary> | ||
void DidVcsRepositoryChange(DidVcsRepositoryChangeParams parameters); | ||
|
||
/// <summary> | ||
/// Returns the currently matched Sonar Project branch. | ||
/// Might return a null value in <see cref="GetMatchedSonarProjectBranchResponse" /> if no matching happened. | ||
/// </summary> | ||
Task<GetMatchedSonarProjectBranchResponse> GetMatchedSonarProjectBranchAsync(GetMatchedSonarProjectBranchParams parameters); | ||
} |