-
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-1543 Add shouldUseEnterpriseCSharpAnalyzer SlCore RPC method (#5773
- Loading branch information
1 parent
97b3773
commit 6595d14
Showing
5 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/SLCore.UnitTests/Service/Analysis/ShouldUseEnterpriseCSharpAnalyzerParamsTests.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,43 @@ | ||
/* | ||
* 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.Analysis.Models; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Analysis; | ||
|
||
[TestClass] | ||
public class ShouldUseEnterpriseCSharpAnalyzerParamsTests | ||
{ | ||
[TestMethod] | ||
public void Serialize_AsExpected() | ||
{ | ||
var testSubject = new ShouldUseEnterpriseCSharpAnalyzerParams("CONFIGURATION_ID"); | ||
const string expectedString = """ | ||
{ | ||
"configurationScopeId": "CONFIGURATION_ID" | ||
} | ||
"""; | ||
|
||
var serializedString = JsonConvert.SerializeObject(testSubject, Formatting.Indented); | ||
|
||
serializedString.Should().Be(expectedString); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/SLCore.UnitTests/Service/Analysis/ShouldUseEnterpriseCSharpAnalyzerResponseTests.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,56 @@ | ||
/* | ||
* 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.Analysis.Models; | ||
using SonarLint.VisualStudio.SLCore.Service.Telemetry; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Analysis; | ||
|
||
[TestClass] | ||
public class ShouldUseEnterpriseCSharpAnalyzerResponseTests | ||
{ | ||
[TestMethod] | ||
public void Serialize_AsExpected() | ||
{ | ||
var testSubject = new ShouldUseEnterpriseCSharpAnalyzerResponse(true); | ||
const string expectedString = """ | ||
{ | ||
"shouldUseEnterpriseAnalyzer": true | ||
} | ||
"""; | ||
|
||
var serializedString = JsonConvert.SerializeObject(testSubject, Formatting.Indented); | ||
|
||
serializedString.Should().Be(expectedString); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(true)] | ||
[DataRow(false)] | ||
public void Deserialized_AsExpected(bool shouldUseEnterpriseAnalyzer) | ||
{ | ||
var expected = new ShouldUseEnterpriseCSharpAnalyzerResponse(shouldUseEnterpriseAnalyzer); | ||
var serialized = $"{{\"shouldUseEnterpriseAnalyzer\":{shouldUseEnterpriseAnalyzer.ToString().ToLower()}}}"; | ||
|
||
JsonConvert.DeserializeObject<ShouldUseEnterpriseCSharpAnalyzerResponse>(serialized).Should().BeEquivalentTo(expected); | ||
} | ||
} |
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,31 @@ | ||
/* | ||
* 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.Core; | ||
using SonarLint.VisualStudio.SLCore.Protocol; | ||
using SonarLint.VisualStudio.SLCore.Service.Analysis.Models; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.Service.Analysis; | ||
|
||
[JsonRpcClass("analysis")] | ||
public interface IRoslynAnalyzerService : ISLCoreService | ||
{ | ||
Task<ShouldUseEnterpriseCSharpAnalyzerResponse> ShouldUseEnterpriseCSharpAnalyzerAsync(ShouldUseEnterpriseCSharpAnalyzerParams shouldUseEnterpriseCsharpParams); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/SLCore/Service/Analysis/Models/ShouldUseEnterpriseCSharpAnalyzerParams.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.Analysis.Models; | ||
|
||
public record ShouldUseEnterpriseCSharpAnalyzerParams(string configurationScopeId); |
23 changes: 23 additions & 0 deletions
23
src/SLCore/Service/Analysis/Models/ShouldUseEnterpriseCSharpAnalyzerResponse.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.Analysis.Models; | ||
|
||
public record ShouldUseEnterpriseCSharpAnalyzerResponse(bool shouldUseEnterpriseAnalyzer); |