diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs index 3aa3bea65e1a2..41fe21c197552 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs @@ -66,7 +66,7 @@ public async Task CreatingDirectoryWatchRequestsDirectoryWatch() var watcher = GetSingleFileWatcher(dynamicCapabilitiesRpcTarget); - Assert.Equal(tempDirectory.Path, watcher.GlobPattern.Second.BaseUri.First.LocalPath); + Assert.Equal(tempDirectory.Path, watcher.GlobPattern.Second.BaseUri.Second.LocalPath); Assert.Equal("**/*", watcher.GlobPattern.Second.Pattern); // Get rid of the registration and it should be gone again @@ -98,7 +98,7 @@ public async Task CreatingFileWatchRequestsFileWatch() var watcher = GetSingleFileWatcher(dynamicCapabilitiesRpcTarget); - Assert.Equal("Z:\\", watcher.GlobPattern.Second.BaseUri.First.LocalPath); + Assert.Equal("Z:\\", watcher.GlobPattern.Second.BaseUri.Second.LocalPath); Assert.Equal("SingleFile.txt", watcher.GlobPattern.Second.Pattern); // Get rid of the registration and it should be gone again diff --git a/src/LanguageServer/Protocol/Protocol/Converters/SumConverter.cs b/src/LanguageServer/Protocol/Protocol/Converters/SumConverter.cs index d8fb1d10670a9..dd972bc7eb357 100644 --- a/src/LanguageServer/Protocol/Protocol/Converters/SumConverter.cs +++ b/src/LanguageServer/Protocol/Protocol/Converters/SumConverter.cs @@ -259,6 +259,13 @@ public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions var sumValue = value.Value; + // behavior from DocumentUriConverter + if (sumValue is Uri) + { + writer.WriteStringValue(sumValue.ToString()); + return; + } + if (sumValue != null) { JsonSerializer.Serialize(writer, sumValue, options); @@ -288,6 +295,7 @@ private static bool IsTokenCompatibleWithType(ref Utf8JsonReader reader, SumConv break; case JsonTokenType.String: isCompatible = unionTypeInfo.Type == typeof(string) || + unionTypeInfo.Type == typeof(Uri) || typeof(IStringEnum).IsAssignableFrom(unionTypeInfo.Type); break; } diff --git a/src/LanguageServer/Protocol/Protocol/FileOperations/RelativePattern.cs b/src/LanguageServer/Protocol/Protocol/FileOperations/RelativePattern.cs index f4d9994a825e9..6126ef4a7c3b7 100644 --- a/src/LanguageServer/Protocol/Protocol/FileOperations/RelativePattern.cs +++ b/src/LanguageServer/Protocol/Protocol/FileOperations/RelativePattern.cs @@ -21,7 +21,7 @@ internal class RelativePattern /// [JsonPropertyName("baseUri")] [JsonRequired] - public SumType BaseUri { get; init; } + public SumType BaseUri { get; init; } /// /// The actual glob pattern. See Glob Pattern for more detail.