Skip to content

Commit

Permalink
SLVS-1650 Update SLCore to 10.11.0.79687 (#5869)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgii-borovinskikh-sonarsource authored Dec 3, 2024
1 parent d4c746a commit 94909a6
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 47 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.18.0.28572</EmbeddedSonarJSAnalyzerVersion>
<EmbeddedSonarSecretsJarVersion>2.19.0.4883</EmbeddedSonarSecretsJarVersion>
<!-- SLOOP: Binaries for SonarLint Out Of Process -->
<EmbeddedSloopVersion>10.10.0.79572</EmbeddedSloopVersion>
<EmbeddedSloopVersion>10.11.0.79687</EmbeddedSloopVersion>
</PropertyGroup>
</Project>
15 changes: 9 additions & 6 deletions src/Integration.UnitTests/LocalServices/FileTrackerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void MefCtor_CheckExports()
MefTestHelpers.CreateExport<IClientFileDtoFactory>(),
MefTestHelpers.CreateExport<ILogger>());
}

[TestMethod]
public void AddFiles_ServiceProviderFailed_LogsError()
{
Expand All @@ -56,7 +56,7 @@ public void AddFiles_ServiceProviderFailed_LogsError()
var testLogger = new TestLogger();

var testSubject = new FileTracker(serviceProvider, activeConfigScopeTracker, threadHandling, clientFileDtoFactory, testLogger);

testSubject.AddFiles(new SourceFile("C:\\Users\\test\\TestProject\\AFile.cs"));

testLogger.AssertOutputStrings($"[FileTracker] {SLCoreStrings.ServiceProviderNotInitialized}");
Expand All @@ -72,7 +72,8 @@ public void AddFiles_ShouldForwardFilesToSlCore()
testSubject.AddFiles(new SourceFile("C:\\Users\\test\\TestProject\\AFile.cs"));

result.removedFiles.Should().BeEmpty();
result.addedOrChangedFiles.Should().ContainSingle();
result.addedFiles.Should().BeEmpty();
result.changedFiles.Should().ContainSingle();
}

[TestMethod]
Expand All @@ -86,7 +87,8 @@ public void RemoveFiles_ShouldForwardFilesToSlCore()

result.removedFiles.Should().ContainSingle();
result.removedFiles[0].Should().BeEquivalentTo(new FileUri("C:\\Users\\test\\TestProject\\AFile.cs"));
result.addedOrChangedFiles.Should().BeEmpty();
result.addedFiles.Should().BeEmpty();
result.changedFiles.Should().BeEmpty();
}

[TestMethod]
Expand All @@ -101,7 +103,8 @@ public void RenameFiles_ShouldForwardFilesToSlCore()

result.removedFiles.Should().ContainSingle();
result.removedFiles[0].Should().BeEquivalentTo(new FileUri("C:\\Users\\test\\TestProject\\AFile.cs"));
result.addedOrChangedFiles.Should().ContainSingle();
result.addedFiles.Should().BeEmpty();
result.changedFiles.Should().ContainSingle();
}

private static FileTracker CreateTestSubject(out IFileRpcSLCoreService slCoreService)
Expand All @@ -124,7 +127,7 @@ private static FileTracker CreateTestSubject(out IFileRpcSLCoreService slCoreSer
.Returns(async info => await info.Arg<Func<Task<int>>>()());

var logger = Substitute.For<ILogger>();

return new FileTracker(serviceProvider, activeConfigScopeTracker, threadHandling, clientFileDtoFactory, logger);
}
}
12 changes: 7 additions & 5 deletions src/Integration/LocalServices/FileTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ public void RenameFiles(string[] beforeRenameFiles, SourceFile[] afterRenameFile
.Forget();
}

private void NotifySlCoreFilesChanged(string[] removedFiles, SourceFile[] addedFiles)
private void NotifySlCoreFilesChanged(string[] removedFiles, SourceFile[] addedOrChangedFiles)
{
if (serviceProvider.TryGetTransientService(out IFileRpcSLCoreService fileRpcSlCoreService) && activeConfigScopeTracker.Current is {} configScope)
if (serviceProvider.TryGetTransientService(out IFileRpcSLCoreService fileRpcSlCoreService) && activeConfigScopeTracker.Current is {} configScope)
{
var clientFiles = addedFiles.Select(sourceFile => clientFileDtoFactory.Create(configScope.Id, configScope.RootPath, sourceFile)).ToList();
var clientFiles = addedOrChangedFiles.Select(sourceFile => clientFileDtoFactory.Create(configScope.Id, configScope.RootPath, sourceFile)).ToList();
var removedFileUris = removedFiles.Select(f => new FileUri(f)).ToList();

fileRpcSlCoreService.DidUpdateFileSystem(new DidUpdateFileSystemParams(
removedFileUris, clientFiles));
/* we're only sending changed files here as it is complicated to implement the proper tracking of added files
AND `changed` files that were actually added are recognized as added by SLCore
https://github.com/SonarSource/sonarlint-core/pull/1163/files#diff-070e6ef952d4a71245d92ea8f281c5a56050e8992179cde3955d4b1530dff664R152 */
fileRpcSlCoreService.DidUpdateFileSystem(new DidUpdateFileSystemParams(removedFileUris, [], clientFiles));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public void Convert_CalculatesChecksumForCodeSnippet()
var issue = testSubject.Convert(new IssueDetailDto("key",
"ruleKey",
"ide\\path",
"branch",
"pr",
"msg",
"today",
codeSnippet,
Expand All @@ -83,8 +81,6 @@ public void Convert_PathTranslated()
var issue = testSubject.Convert(new IssueDetailDto("key",
"ruleKey",
"ide\\path",
"branch",
"pr",
"msg",
"today",
"codeSnippet",
Expand Down Expand Up @@ -112,8 +108,6 @@ public void Convert_PrimaryRangeAndMessagePreserved()
var issue = testSubject.Convert(new IssueDetailDto("key",
"ruleKey",
"ide\\path",
"branch",
"pr",
message,
"today",
"codeSnippet",
Expand All @@ -138,8 +132,6 @@ public void Convert_RuleKeyPreserved()
var issue = testSubject.Convert(new IssueDetailDto("key",
ruleKey,
"ide\\path",
"branch",
"pr",
"msg",
"today",
"codeSnippet",
Expand All @@ -161,8 +153,6 @@ public void Convert_FlowsPreservedWithPathTranslation()
var issue = testSubject.Convert(new IssueDetailDto("key",
"rule",
"ide\\path",
"branch",
"pr",
"msg",
"today",
"codeSnippet",
Expand Down
10 changes: 5 additions & 5 deletions src/IssueViz.UnitTests/OpenInIDE/OpenIssueInIdeHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public void MefCtor_CheckIsSingleton()
{
MefTestHelpers.CheckIsSingletonMefComponent<OpenIssueInIdeHandler>();
}

[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
public void Show_CallsBaseHandler(bool isTaint)
{
const string configScope = "configscope";
var issue = new IssueDetailDto(default, default, default, default, default, default,
var issue = new IssueDetailDto(default, default, default, default,
default, default, isTaint, default, default);
var testSubject = CreateTestSubject(out var handler, out var converter);

testSubject.Show(issue, configScope);

handler.Received().ShowIssue(issue, configScope, converter, isTaint ? IssueListIds.TaintId : IssueListIds.ErrorListId, null);
}

Expand All @@ -66,5 +66,5 @@ private OpenIssueInIdeHandler CreateTestSubject(out IOpenInIdeHandlerImplementat
issueOpenInIdeConverter = Substitute.For<IIssueDetailDtoToAnalysisIssueConverter>();
return new OpenIssueInIdeHandler(openInIdeHandlerImplementation,
issueOpenInIdeConverter);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ public void MefCtor_CheckIsSingleton()
[TestMethod]
public void ShowIssue_ForwardsToHandler()
{
var dummyIssue = new IssueDetailDto(default, default, default, default,
default, default, default, default,
var dummyIssue = new IssueDetailDto(default, default, default, default, default, default,
default, default, default);
const string configScopeId = "configscope";
var openIssueInIdeHandler = Substitute.For<IOpenIssueInIdeHandler>();
var testSubject = new ShowInIdeListener(openIssueInIdeHandler, Substitute.For<IOpenHotspotInIdeHandler>());

testSubject.ShowIssue(new ShowIssueParams(configScopeId, dummyIssue));

openIssueInIdeHandler.Received().Show(dummyIssue, configScopeId);
}

[TestMethod]
public void ShowHotspot_ForwardsToHandler()
{
Expand All @@ -66,9 +65,9 @@ public void ShowHotspot_ForwardsToHandler()
const string configScopeId = "configscope";
var openHotspotInIdeHandler = Substitute.For<IOpenHotspotInIdeHandler>();
var testSubject = new ShowInIdeListener(Substitute.For<IOpenIssueInIdeHandler>(), openHotspotInIdeHandler);

testSubject.ShowHotspot(new ShowHotspotParams(configScopeId, dummyIssue));

openHotspotInIdeHandler.Received().Show(dummyIssue, configScopeId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class IOpenInIdeIssueTests
public void Issue_ReturnsType_DependingOnIsTaintProperty(bool isTaint)
{
const string issueKey = "key123";
var testSubject = new IssueDetailDto(issueKey, default, default, default, default,
var testSubject = new IssueDetailDto(issueKey, default, default,
default, default, default, isTaint, default, default);

testSubject.Key.Should().BeSameAs(issueKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public void DeserializesCorrectly()
new IssueDetailDto("issueKeyValue",
"rule:S123",
"idepath",
"feature/sloop-open-in-ide",
"pr#123",
"my message",
"2024-01-01",
"a==b",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,49 @@ public void Serialize_AsExpected()
new("file:///tmp/junit14012097140227905793/Bar.cs")
};

var addedOrChangedFiles = new List<ClientFileDto>
var addedFiles = new List<ClientFileDto>
{
new(new FileUri("file:///c:/Users/test/project/Baz.cs"), "Baz.cs", "CONFIG_SCOPE_ID", false,
"utf8", "C:\\Users\\test\\project", "CONTENT")
new(new FileUri("file:///c:/Users/test/project1/Baz.cs"), "Baz.cs", "CONFIG_SCOPE_ID", false,
"utf8", "C:\\Users\\test\\project1", "CONTENT")
};

var testSubject = new DidUpdateFileSystemParams(removedFiles, addedOrChangedFiles);
var changedFiles = new List<ClientFileDto>
{
new(new FileUri("file:///c:/Users/test/project2/ABOBA.cs"), "ABOBA.cs", "CONFIG_SCOPE_ID", true,
"utf16", "C:\\Users\\test\\project2", "CONTENT2")
};

var testSubject = new DidUpdateFileSystemParams(removedFiles, addedFiles, changedFiles);

const string expectedString = """
{
"removedFiles": [
"file:///tmp/junit14012097140227905793/Foo.cs",
"file:///tmp/junit14012097140227905793/Bar.cs"
],
"addedOrChangedFiles": [
"addedFiles": [
{
"uri": "file:///c:/Users/test/project/Baz.cs",
"uri": "file:///c:/Users/test/project1/Baz.cs",
"ideRelativePath": "Baz.cs",
"configScopeId": "CONFIG_SCOPE_ID",
"isTest": false,
"charset": "utf8",
"fsPath": "C:\\Users\\test\\project",
"fsPath": "C:\\Users\\test\\project1",
"content": "CONTENT",
"isUserDefined": true
}
],
"changedFiles": [
{
"uri": "file:///c:/Users/test/project2/ABOBA.cs",
"ideRelativePath": "ABOBA.cs",
"configScopeId": "CONFIG_SCOPE_ID",
"isTest": true,
"charset": "utf16",
"fsPath": "C:\\Users\\test\\project2",
"content": "CONTENT2",
"isUserDefined": true
}
]
}
""";
Expand Down
2 changes: 0 additions & 2 deletions src/SLCore/Listener/Visualization/Models/IssueDetailDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public record IssueDetailDto(
string issueKey,
string ruleKey,
string ideFilePath,
string branch,
string pullRequest,
string message,
string creationDate,
string codeSnippet,
Expand Down
2 changes: 1 addition & 1 deletion src/SLCore/Service/File/DidUpdateFileSystemParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

namespace SonarLint.VisualStudio.SLCore.Service.File;

public record DidUpdateFileSystemParams(List<FileUri> removedFiles, List<ClientFileDto> addedOrChangedFiles);
public record DidUpdateFileSystemParams(List<FileUri> removedFiles, List<ClientFileDto> addedFiles, List<ClientFileDto> changedFiles);

0 comments on commit 94909a6

Please sign in to comment.