Skip to content

Commit fb92f76

Browse files
SLVS-1543 Add shouldUseEnterpriseCSharpAnalyzer SlCore RPC method (#5773)
1 parent 7cf1ffe commit fb92f76

File tree

5 files changed

+176
-0
lines changed

5 files changed

+176
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* SonarLint for Visual Studio
3+
* Copyright (C) 2016-2024 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
21+
using Newtonsoft.Json;
22+
using SonarLint.VisualStudio.SLCore.Service.Analysis.Models;
23+
24+
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Analysis;
25+
26+
[TestClass]
27+
public class ShouldUseEnterpriseCSharpAnalyzerParamsTests
28+
{
29+
[TestMethod]
30+
public void Serialize_AsExpected()
31+
{
32+
var testSubject = new ShouldUseEnterpriseCSharpAnalyzerParams("CONFIGURATION_ID");
33+
const string expectedString = """
34+
{
35+
"configurationScopeId": "CONFIGURATION_ID"
36+
}
37+
""";
38+
39+
var serializedString = JsonConvert.SerializeObject(testSubject, Formatting.Indented);
40+
41+
serializedString.Should().Be(expectedString);
42+
}
43+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* SonarLint for Visual Studio
3+
* Copyright (C) 2016-2024 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
21+
22+
using Newtonsoft.Json;
23+
using SonarLint.VisualStudio.SLCore.Service.Analysis.Models;
24+
using SonarLint.VisualStudio.SLCore.Service.Telemetry;
25+
26+
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Analysis;
27+
28+
[TestClass]
29+
public class ShouldUseEnterpriseCSharpAnalyzerResponseTests
30+
{
31+
[TestMethod]
32+
public void Serialize_AsExpected()
33+
{
34+
var testSubject = new ShouldUseEnterpriseCSharpAnalyzerResponse(true);
35+
const string expectedString = """
36+
{
37+
"shouldUseEnterpriseAnalyzer": true
38+
}
39+
""";
40+
41+
var serializedString = JsonConvert.SerializeObject(testSubject, Formatting.Indented);
42+
43+
serializedString.Should().Be(expectedString);
44+
}
45+
46+
[TestMethod]
47+
[DataRow(true)]
48+
[DataRow(false)]
49+
public void Deserialized_AsExpected(bool shouldUseEnterpriseAnalyzer)
50+
{
51+
var expected = new ShouldUseEnterpriseCSharpAnalyzerResponse(shouldUseEnterpriseAnalyzer);
52+
var serialized = $"{{\"shouldUseEnterpriseAnalyzer\":{shouldUseEnterpriseAnalyzer.ToString().ToLower()}}}";
53+
54+
JsonConvert.DeserializeObject<ShouldUseEnterpriseCSharpAnalyzerResponse>(serialized).Should().BeEquivalentTo(expected);
55+
}
56+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* SonarLint for Visual Studio
3+
* Copyright (C) 2016-2024 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
21+
using SonarLint.VisualStudio.SLCore.Core;
22+
using SonarLint.VisualStudio.SLCore.Protocol;
23+
using SonarLint.VisualStudio.SLCore.Service.Analysis.Models;
24+
25+
namespace SonarLint.VisualStudio.SLCore.Service.Analysis;
26+
27+
[JsonRpcClass("analysis")]
28+
public interface IRoslynAnalyzerService : ISLCoreService
29+
{
30+
Task<ShouldUseEnterpriseCSharpAnalyzerResponse> ShouldUseEnterpriseCSharpAnalyzerAsync(ShouldUseEnterpriseCSharpAnalyzerParams shouldUseEnterpriseCsharpParams);
31+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SonarLint for Visual Studio
3+
* Copyright (C) 2016-2024 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
21+
namespace SonarLint.VisualStudio.SLCore.Service.Analysis.Models;
22+
23+
public record ShouldUseEnterpriseCSharpAnalyzerParams(string configurationScopeId);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SonarLint for Visual Studio
3+
* Copyright (C) 2016-2024 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
21+
namespace SonarLint.VisualStudio.SLCore.Service.Analysis.Models;
22+
23+
public record ShouldUseEnterpriseCSharpAnalyzerResponse(bool shouldUseEnterpriseAnalyzer);

0 commit comments

Comments
 (0)