Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Roslyn to version 4.8.0-3.23475.6 #2567

Merged
merged 12 commits into from
Oct 4, 2023
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<MicrosoftTestPackageVersion>17.6.0</MicrosoftTestPackageVersion>
<MSBuildPackageVersion>17.3.2</MSBuildPackageVersion>
<NuGetPackageVersion>6.8.0-preview.1.69</NuGetPackageVersion>
<RoslynPackageVersion>4.8.0-1.23419.1</RoslynPackageVersion>
<RoslynPackageVersion>4.8.0-3.23475.6</RoslynPackageVersion>
<XunitPackageVersion>2.4.1</XunitPackageVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#nullable enable

using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Logging;
using OmniSharp.Mef;
using OmniSharp.Models.v1.SourceGeneratedFile;
using System;
using System.Collections.Generic;
using System.Composition;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Logging;
using OmniSharp.Mef;
using OmniSharp.Models.v1.SourceGeneratedFile;

namespace OmniSharp.Roslyn.CSharp.Services.Navigation
{
Expand All @@ -20,6 +22,9 @@ public class SourceGeneratedFileService :
IRequestHandler<UpdateSourceGeneratedFileRequest, UpdateSourceGeneratedFileResponse>,
IRequestHandler<SourceGeneratedFileClosedRequest, SourceGeneratedFileClosedResponse>
{
private static MethodInfo? CreateDocumentIdFromSerialized => typeof(DocumentId)
JoeRobich marked this conversation as resolved.
Show resolved Hide resolved
.GetMethod("CreateFromSerialized", BindingFlags.Static | BindingFlags.NonPublic, binder: null, types: new[] { typeof(ProjectId), typeof(Guid), typeof(bool), typeof(string) }, modifiers: null);

private readonly OmniSharpWorkspace _workspace;
private readonly ILogger _logger;
private readonly Dictionary<DocumentId, VersionStamp> _lastSentVerisons = new();
Expand Down Expand Up @@ -100,6 +105,10 @@ public Task<SourceGeneratedFileClosedResponse> Handle(SourceGeneratedFileClosedR
return SourceGeneratedFileClosedResponse.Instance;
}

private DocumentId GetId(SourceGeneratedFileInfo info) => DocumentId.CreateFromSerialized(ProjectId.CreateFromSerialized(info.ProjectGuid), info.DocumentGuid);
private DocumentId GetId(SourceGeneratedFileInfo info)
{
return CreateDocumentIdFromSerialized?.Invoke(null, new object?[] { ProjectId.CreateFromSerialized(info.ProjectGuid), info.DocumentGuid, true, null }) as DocumentId
?? DocumentId.CreateFromSerialized(ProjectId.CreateFromSerialized(info.ProjectGuid), info.DocumentGuid);
}
}
}
22 changes: 11 additions & 11 deletions tests/OmniSharp.Lsp.Tests/OmnisharpCompletionHandlerFacts.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using TestUtility;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -288,7 +288,7 @@ public async Task ImportCompletion_OnLine0(string filename)
Assert.Single(resolved.AdditionalTextEdits);
var additionalEdit = resolved.AdditionalTextEdits.First();
Assert.Equal(NormalizeNewlines("using System;\n\n"),
additionalEdit.NewText);
NormalizeNewlines(additionalEdit.NewText));
Assert.Equal(0, additionalEdit.Range.Start.Line);
Assert.Equal(0, additionalEdit.Range.Start.Character);
Assert.Equal(0, additionalEdit.Range.End.Line);
Expand Down Expand Up @@ -375,12 +375,12 @@ public class C3

Assert.Single(resolved.AdditionalTextEdits);
var additionalEdit = resolved.AdditionalTextEdits.First();
Assert.Equal(NormalizeNewlines("N2;\nusing "),
Assert.Equal(NormalizeNewlines("using N2;\n"),
additionalEdit.NewText);
Assert.Equal(1, additionalEdit.Range.Start.Line);
Assert.Equal(6, additionalEdit.Range.Start.Character);
Assert.Equal(0, additionalEdit.Range.Start.Character);
Assert.Equal(1, additionalEdit.Range.End.Line);
Assert.Equal(6, additionalEdit.Range.End.Character);
Assert.Equal(0, additionalEdit.Range.End.Character);
VerifySortOrders(completions.Items);
}

Expand Down Expand Up @@ -1530,7 +1530,7 @@ public void M()
protected async Task<CompletionList> FindCompletionsAsync(string filename, string source, char? triggerChar = null, TestFile[] additionalFiles = null)
{
var bufferPath = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}somepath{Path.DirectorySeparatorChar}{filename}";
var testFile = new TestFile(bufferPath, source);
var testFile = new TestFile(bufferPath, NormalizeNewlines(source));

var files = new[] { testFile };
if (additionalFiles is object)
Expand Down Expand Up @@ -1588,7 +1588,7 @@ private async Task EnableImportCompletion()
}

private static string NormalizeNewlines(string str)
=> str.Replace("\r\n", Environment.NewLine);
=> str.Replace("\r\n", "\n");

private static void VerifySortOrders(IEnumerable<CompletionItem> items)
{
Expand Down
12 changes: 6 additions & 6 deletions tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public async Task ImportCompletion_OnLine0(string filename, bool useAsyncComplet
Assert.Single(resolved.Item.AdditionalTextEdits);
var additionalEdit = resolved.Item.AdditionalTextEdits[0];
Assert.Equal(NormalizeNewlines("using System;\n\n"),
additionalEdit.NewText);
NormalizeNewlines(additionalEdit.NewText));
Assert.Equal(0, additionalEdit.StartLine);
Assert.Equal(0, additionalEdit.StartColumn);
Assert.Equal(0, additionalEdit.EndLine);
Expand Down Expand Up @@ -395,12 +395,12 @@ public class C3

Assert.Single(resolved.Item.AdditionalTextEdits);
var additionalEdit = resolved.Item.AdditionalTextEdits[0];
Assert.Equal(NormalizeNewlines("N2;\nusing "),
Assert.Equal(NormalizeNewlines("using N2;\n"),
additionalEdit.NewText);
Assert.Equal(1, additionalEdit.StartLine);
Assert.Equal(6, additionalEdit.StartColumn);
Assert.Equal(0, additionalEdit.StartColumn);
Assert.Equal(1, additionalEdit.EndLine);
Assert.Equal(6, additionalEdit.EndColumn);
Assert.Equal(0, additionalEdit.EndColumn);
VerifySortOrders(completions.Items);
}

Expand Down Expand Up @@ -2273,7 +2273,7 @@ private CompletionService GetCompletionService(OmniSharpTestHost host)

protected async Task<CompletionResponse> FindCompletionsAsync(string filename, string source, OmniSharpTestHost testHost, char? triggerChar = null, TestFile[] additionalFiles = null, bool forceExpandedCompletionIndexCreation = false)
{
var testFile = new TestFile(filename, source);
var testFile = new TestFile(filename, NormalizeNewlines(source));

var files = new[] { testFile };
if (additionalFiles is object)
Expand Down Expand Up @@ -2331,7 +2331,7 @@ private Task<CompletionAfterInsertResponse> AfterInsertResponse(CompletionItem c
}

private static string NormalizeNewlines(string str)
=> str.Replace("\r\n", Environment.NewLine);
=> str.Replace("\r\n", "\n");

private static void VerifySortOrders(IReadOnlyList<CompletionItem> items)
{
Expand Down
Loading