diff --git a/Directory.Packages.props b/Directory.Packages.props index a989f54d1bf..8c678eb5169 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,8 +6,8 @@ --> <_MicrosoftWebToolsPackageVersion>17.11.11-preview-0001 - <_MicrosoftVisualStudioShellPackagesVersion>17.12.39557-preview.2.1 - <_MicrosoftVisualStudioPackagesVersion>17.12.145-preview + <_MicrosoftVisualStudioShellPackagesVersion>17.13.40008 + <_MicrosoftVisualStudioPackagesVersion>17.13.226 <_VisualStudioLanguageServerProtocolVersion>17.12.1-preview <_MicrosoftExtensionsPackageVersion>8.0.0 <_BasicReferenceAssembliesVersion>1.7.2 @@ -17,7 +17,7 @@ <_RoslynDiagnosticAnalyzersPackageVersion>3.11.0-beta1.24508.2 <_MicrosoftVisualStudioLanguageServicesPackageVersion>$(MicrosoftVisualStudioLanguageServicesPackageVersion) <_XunitPackageVersion>2.9.2 - <_MicrosoftBuildPackageVersion>17.12.0-preview-24426-07 + <_MicrosoftBuildPackageVersion>17.13.9 @@ -27,7 +27,7 @@ - + @@ -47,6 +47,7 @@ + @@ -55,7 +56,6 @@ - @@ -84,14 +84,14 @@ - + - + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 5c6188da700..495eec823ff 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -11,82 +11,82 @@ d794781cc75921b4ebbefe2eabdb0d6cd1713005 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 - + https://github.com/dotnet/roslyn - 5970c1a8588cc6bac346d9ad3eebb41321713ab0 + dcc8ef293ae1da2efc03956e3ecdb824c18e5bf3 diff --git a/eng/Versions.props b/eng/Versions.props index d48877a5bea..7f81b58ab37 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -53,25 +53,25 @@ 9.0.0-beta.25111.5 1.0.0-beta.23475.1 1.0.0-beta.23475.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 - 4.14.0-1.25071.1 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 + 4.14.0-2.25123.16 - + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/ProjectContexts/ProjectContextsEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/ProjectContexts/ProjectContextsEndpointTest.cs index 283c0ebbe4a..dd6a5cab526 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/ProjectContexts/ProjectContextsEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/ProjectContexts/ProjectContextsEndpointTest.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.LanguageServer.ProjectContexts; using Microsoft.CodeAnalysis.Razor.ProjectSystem; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RangeExtensionsTests.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RangeExtensionsTests.cs index 98e5dc223d1..54ffd326cb3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RangeExtensionsTests.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RangeExtensionsTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; namespace Microsoft.AspNetCore.Razor.LanguageServer.Test; @@ -13,8 +12,8 @@ public class RangeExtensionsTests public void CompareTo_StartAndEndAreSame_ReturnsZero() { // Arrange - var range1 = VsLspFactory.CreateRange(1, 2, 3, 4); - var range2 = VsLspFactory.CreateRange(1, 2, 3, 4); + var range1 = LspFactory.CreateRange(1, 2, 3, 4); + var range2 = LspFactory.CreateRange(1, 2, 3, 4); // Act var result = range1.CompareTo(range2); @@ -27,8 +26,8 @@ public void CompareTo_StartAndEndAreSame_ReturnsZero() public void CompareTo_StartOfThisRangeIsBeforeOther_ReturnsNegative() { // Arrange - var range1 = VsLspFactory.CreateRange(1, 2, 3, 4); - var range2 = VsLspFactory.CreateRange(2, 2, 3, 4); + var range1 = LspFactory.CreateRange(1, 2, 3, 4); + var range2 = LspFactory.CreateRange(2, 2, 3, 4); // Act var result = range1.CompareTo(range2); @@ -41,8 +40,8 @@ public void CompareTo_StartOfThisRangeIsBeforeOther_ReturnsNegative() public void CompareTo_EndOfThisRangeIsBeforeOther_ReturnsNegative() { // Arrange - var range1 = VsLspFactory.CreateRange(1, 2, 3, 4); - var range2 = VsLspFactory.CreateRange(1, 2, 4, 4); + var range1 = LspFactory.CreateRange(1, 2, 3, 4); + var range2 = LspFactory.CreateRange(1, 2, 4, 4); // Act var result = range1.CompareTo(range2); @@ -55,8 +54,8 @@ public void CompareTo_EndOfThisRangeIsBeforeOther_ReturnsNegative() public void CompareTo_StartOfThisRangeIsAfterOther_ReturnsPositive() { // Arrange - var range1 = VsLspFactory.CreateRange(2, 2, 3, 4); - var range2 = VsLspFactory.CreateRange(1, 2, 3, 4); + var range1 = LspFactory.CreateRange(2, 2, 3, 4); + var range2 = LspFactory.CreateRange(1, 2, 3, 4); // Act var result = range1.CompareTo(range2); @@ -69,8 +68,8 @@ public void CompareTo_StartOfThisRangeIsAfterOther_ReturnsPositive() public void CompareTo_EndOfThisRangeIsAfterOther_ReturnsPositive() { // Arrange - var range1 = VsLspFactory.CreateRange(1, 2, 4, 4); - var range2 = VsLspFactory.CreateRange(1, 2, 3, 4); + var range1 = LspFactory.CreateRange(1, 2, 4, 4); + var range2 = LspFactory.CreateRange(1, 2, 3, 4); // Act var result = range1.CompareTo(range2); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorConfigurationEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorConfigurationEndpointTest.cs index c044d347085..5a597d5c2c8 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorConfigurationEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorConfigurationEndpointTest.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorFileChangeDetectorManagerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorFileChangeDetectorManagerTest.cs index 7a1cbed117d..e444725ce54 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorFileChangeDetectorManagerTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorFileChangeDetectorManagerTest.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; @@ -23,7 +22,9 @@ public async Task InitializedAsync_StartsFileChangeDetectors() var initializeParams = new InitializeParams() { - RootUri = VsLspFactory.CreateFilePathUri(initialWorkspaceDirectory), +#pragma warning disable CS0618 // Type or member is obsolete + RootUri = LspFactory.CreateFilePathUri(initialWorkspaceDirectory), +#pragma warning restore CS0618 // Type or member is obsolete }; var capabilitiesManager = new CapabilitiesManager(StrictMock.Of()); @@ -65,7 +66,9 @@ public async Task InitializedAsync_Disposed_ReStopsFileChangeDetectors() var expectedWorkspaceDirectory = "\\\\testpath"; var initializeParams = new InitializeParams() { +#pragma warning disable CS0618 // Type or member is obsolete RootUri = new Uri(expectedWorkspaceDirectory), +#pragma warning restore CS0618 // Type or member is obsolete }; var capabilitiesManager = new CapabilitiesManager(StrictMock.Of()); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs index 86d8179f32b..eca1e68178f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs @@ -18,7 +18,6 @@ using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CommonLanguageServerProtocol.Framework; using Microsoft.Extensions.DependencyInjection; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Nerdbank.Streams; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointDelegationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointDelegationTest.cs index 205d58ad84e..b27e9575d79 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointDelegationTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointDelegationTest.cs @@ -12,7 +12,6 @@ using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; @@ -92,7 +91,7 @@ await projectManager.UpdateAsync(updater => var result = await endpoint.HandleRequestAsync(request, requestContext, DisposalToken); // Assert - var edits = result.DocumentChanges.Value.First.FirstOrDefault().Edits.Select(codeDocument.Source.Text.GetTextChange); + var edits = result.DocumentChanges.Value.First.FirstOrDefault().Edits.Select(e => codeDocument.Source.Text.GetTextChange(((TextEdit)e))); var newText = codeDocument.Source.Text.WithChanges(edits).ToString(); Assert.Equal(expected, newText); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointTest.cs index dad96f7c20e..07731171a3e 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Refactoring/RenameEndpointTest.cs @@ -24,7 +24,6 @@ using Microsoft.CodeAnalysis.Razor.Rename; using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; @@ -116,7 +115,7 @@ public async Task Handle_Rename_FileManipulationNotSupported_ReturnsNull() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(2, 1), + Position = LspFactory.CreatePosition(2, 1), NewName = "Component5" }; @@ -139,7 +138,7 @@ public async Task Handle_Rename_WithNamespaceDirective() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(2, 1), + Position = LspFactory.CreatePosition(2, 1), NewName = "Component5" }; @@ -180,7 +179,7 @@ public async Task Handle_Rename_OnComponentParameter_ReturnsNull() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 14), + Position = LspFactory.CreatePosition(1, 14), NewName = "Test2" }; @@ -203,7 +202,7 @@ public async Task Handle_Rename_OnOpeningBrace_ReturnsNull() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 0), + Position = LspFactory.CreatePosition(1, 0), NewName = "Test2" }; @@ -226,7 +225,7 @@ public async Task Handle_Rename_OnComponentNameLeadingEdge_ReturnsResult() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 1), + Position = LspFactory.CreatePosition(1, 1), NewName = "Test2" }; @@ -249,7 +248,7 @@ public async Task Handle_Rename_OnComponentName_ReturnsResult() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 3), + Position = LspFactory.CreatePosition(1, 3), NewName = "Test2" }; @@ -272,7 +271,7 @@ public async Task Handle_Rename_OnComponentEndTag_ReturnsResult() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 36), + Position = LspFactory.CreatePosition(1, 36), NewName = "Test2" }; @@ -295,7 +294,7 @@ public async Task Handle_Rename_OnComponentNameTrailingEdge_ReturnsResult() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 10), + Position = LspFactory.CreatePosition(1, 10), NewName = "Test2" }; @@ -318,7 +317,7 @@ public async Task Handle_Rename_ComponentInSameFile() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 1), + Position = LspFactory.CreatePosition(1, 1), NewName = "Component5" }; @@ -390,8 +389,8 @@ static IEnumerable GetTextDocumentEdits(WorkspaceEdit workspac return builder .ToArray() .OrderBy(x => x.TextDocument.Uri.ToString()) - .ThenBy(x => x.Edits.First().Range.Start.Line) - .ThenBy(x => x.Edits.First().Range.Start.Character); + .ThenBy(x => ((TextEdit)x.Edits.First()).Range.Start.Line) + .ThenBy(x => ((TextEdit)x.Edits.First()).Range.Start.Character); } } @@ -404,7 +403,7 @@ public async Task Handle_Rename_FullyQualifiedAndNot() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(2, 1), + Position = LspFactory.CreatePosition(2, 1), NewName = "Component5" }; @@ -450,7 +449,7 @@ public async Task Handle_Rename_MultipleFileUsages() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 1), + Position = LspFactory.CreatePosition(1, 1), NewName = "Component5" }; @@ -503,7 +502,7 @@ public async Task Handle_Rename_DifferentDirectories() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 1), + Position = LspFactory.CreatePosition(1, 1), NewName = "TestComponent" }; @@ -571,7 +570,7 @@ public async Task Handle_Rename_SingleServer_CallsDelegatedLanguageServer() var request = new RenameParams { TextDocument = new() { Uri = uri }, - Position = VsLspFactory.CreatePosition(1, 0), + Position = LspFactory.CreatePosition(1, 0), NewName = "Test2" }; @@ -601,7 +600,7 @@ public async Task Handle_Rename_SingleServer_DoesNotDelegateForRazor() var request = new RenameParams { TextDocument = new() { Uri = PathUtilities.GetUri(s_componentWithParamFilePath) }, - Position = VsLspFactory.CreatePosition(0, 1), // This is right after the '@' in '@namespace' + Position = LspFactory.CreatePosition(0, 1), // This is right after the '@' in '@namespace' NewName = "Test2" }; @@ -750,12 +749,12 @@ private static IEnumerable CreateRazorComponentTagHelperDes yield return fullyQualifiedBuilder.Build(); } - private static Action AssertTextEdit(string fileName, int startLine, int startCharacter, int endLine, int endCharacter) + private static Action> AssertTextEdit(string fileName, int startLine, int startCharacter, int endLine, int endCharacter) => edit => { - Assert.Equal(fileName, edit.NewText); + Assert.Equal(fileName, ((TextEdit)edit).NewText); - var range = edit.Range; + var range = ((TextEdit)edit).Range; Assert.Equal(startLine, range.Start.Line); Assert.Equal(startCharacter, range.Start.Character); Assert.Equal(endLine, range.End.Line); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensLegendServiceTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensLegendServiceTest.cs index caea278d09c..f4ae741cf15 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensLegendServiceTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensLegendServiceTest.cs @@ -15,7 +15,7 @@ public class RazorSemanticTokensLegendServiceTest(ITestOutputHelper testOutput) [Fact] public void RazorModifiers_MustStartAfterRoslyn() { - var clientCapabilitiesService = new TestClientCapabilitiesService(new VisualStudio.LanguageServer.Protocol.VSInternalClientCapabilities()); + var clientCapabilitiesService = new TestClientCapabilitiesService(new VSInternalClientCapabilities()); var service = new RazorSemanticTokensLegendService(clientCapabilitiesService); var expected = Math.Pow(2, RazorSemanticTokensAccessor.GetTokenModifiers().Length); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensRefreshEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensRefreshEndpointTest.cs index ef79b93360f..d95f5bc3f4a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensRefreshEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/RazorSemanticTokensRefreshEndpointTest.cs @@ -13,7 +13,6 @@ using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/SemanticTokensTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/SemanticTokensTest.cs index a82c06a93e0..d46f80d6e8d 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/SemanticTokensTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Semantic/SemanticTokensTest.cs @@ -28,7 +28,6 @@ using Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; @@ -42,7 +41,7 @@ public partial class SemanticTokensTest(ITestOutputHelper testOutput) : TagHelpe private static readonly VSInternalServerCapabilities s_semanticTokensServerCapabilities = new() { - SemanticTokensOptions = new() + SemanticTokensOptions = new SemanticTokensOptions() { Full = false, Range = true diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Serialization/PlatformAgnosticClientCapabilitiesJsonConverterTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Serialization/PlatformAgnosticClientCapabilitiesJsonConverterTest.cs index 8d2f84072f0..84d5b73fd84 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Serialization/PlatformAgnosticClientCapabilitiesJsonConverterTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Serialization/PlatformAgnosticClientCapabilitiesJsonConverterTest.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text.Json; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; namespace Microsoft.AspNetCore.Razor.LanguageServer.Serialization; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SignatureHelp/SignatureHelpEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SignatureHelp/SignatureHelpEndpointTest.cs index 646b2085413..b2cc18104bb 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SignatureHelp/SignatureHelpEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SignatureHelp/SignatureHelpEndpointTest.cs @@ -9,7 +9,6 @@ using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.TestLanguageServer.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.TestLanguageServer.cs index a62bd71e06f..90d45a0d1f4 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.TestLanguageServer.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.TestLanguageServer.cs @@ -3,6 +3,8 @@ #nullable disable +extern alias RLSP; + using System; using System.Threading; using System.Threading.Tasks; @@ -13,16 +15,15 @@ using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions; using Microsoft.CodeAnalysis.Razor.Protocol.Diagnostics; using Microsoft.CodeAnalysis.Razor.Protocol.Folding; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; -using DefinitionResult = Microsoft.VisualStudio.LanguageServer.Protocol.SumType< - Microsoft.VisualStudio.LanguageServer.Protocol.Location, - Microsoft.VisualStudio.LanguageServer.Protocol.Location[], - Microsoft.VisualStudio.LanguageServer.Protocol.DocumentLink[]>; -using ImplementationResult = Microsoft.VisualStudio.LanguageServer.Protocol.SumType< - Microsoft.VisualStudio.LanguageServer.Protocol.Location[], - Microsoft.VisualStudio.LanguageServer.Protocol.VSInternalReferenceItem[]>; -using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range; +using DefinitionResult = RLSP::Roslyn.LanguageServer.Protocol.SumType< + RLSP::Roslyn.LanguageServer.Protocol.Location, + RLSP::Roslyn.LanguageServer.Protocol.VSInternalLocation, + RLSP::Roslyn.LanguageServer.Protocol.VSInternalLocation[], + RLSP::Roslyn.LanguageServer.Protocol.DocumentLink[]>; +using ImplementationResult = RLSP::Roslyn.LanguageServer.Protocol.SumType< + RLSP::Roslyn.LanguageServer.Protocol.Location[], + RLSP::Roslyn.LanguageServer.Protocol.VSInternalReferenceItem[]>; namespace Microsoft.AspNetCore.Razor.LanguageServer; @@ -271,7 +272,7 @@ private Task HandleImplementationAsync(T @params) _cancellationToken); } - private Task HandleSignatureHelpAsync(T @params) + private Task HandleSignatureHelpAsync(T @params) { var delegatedParams = Assert.IsType(@params); var delegatedRequest = new SignatureHelpParams() @@ -284,7 +285,7 @@ private Task HandleImplementationAsync(T @params) Position = delegatedParams.ProjectedPosition, }; - return _csharpServer.ExecuteRequestAsync( + return _csharpServer.ExecuteRequestAsync( Methods.TextDocumentSignatureHelpName, delegatedRequest, _cancellationToken); @@ -341,7 +342,7 @@ public Task SendNotificationAsync(string method, CancellationToken cancellationT throw new NotImplementedException(); } - private Task HandleValidateBreakpointRangeAsync(T @params) + private Task HandleValidateBreakpointRangeAsync(T @params) { var delegatedParams = Assert.IsType(@params); var delegatedRequest = new VSInternalValidateBreakableRangeParams() @@ -354,7 +355,7 @@ private Task HandleValidateBreakpointRangeAsync(T @params) Range = delegatedParams.ProjectedRange, }; - return _csharpServer.ExecuteRequestAsync( + return _csharpServer.ExecuteRequestAsync( VSInternalMethods.TextDocumentValidateBreakableRangeName, delegatedRequest, _cancellationToken); } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.cs index c2c8405e394..fae074ab86f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SingleServerDelegatingEndpointTestBase.cs @@ -12,7 +12,6 @@ using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SpellCheck/DocumentSpellCheckEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SpellCheck/DocumentSpellCheckEndpointTest.cs index a81ed10c7f1..d73b6f418c8 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SpellCheck/DocumentSpellCheckEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/SpellCheck/DocumentSpellCheckEndpointTest.cs @@ -10,7 +10,6 @@ using Microsoft.CodeAnalysis.Razor.SpellCheck; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TestClient.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TestClient.cs index c99ebf5cd55..436855cc6c8 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TestClient.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TestClient.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; using Microsoft.CodeAnalysis.Razor.Protocol; -using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.AspNetCore.Razor.LanguageServer; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceDiagnosticRefreshTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceDiagnosticRefreshTest.cs index 33253217f7a..72383bad6a1 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceDiagnosticRefreshTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceDiagnosticRefreshTest.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; using Microsoft.CodeAnalysis.Razor.ProjectSystem; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceSemanticTokensRefreshNotifierTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceSemanticTokensRefreshNotifierTest.cs index 3cf9d0fbc02..f604e190c91 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceSemanticTokensRefreshNotifierTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WorkspaceSemanticTokensRefreshNotifierTest.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Test; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WrapWithTag/WrapWithTagEndpointTests.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WrapWithTag/WrapWithTagEndpointTests.cs index ce85b88177c..05a86897d56 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WrapWithTag/WrapWithTagEndpointTests.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/WrapWithTag/WrapWithTagEndpointTests.cs @@ -10,7 +10,6 @@ using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Moq; using Xunit; using Xunit.Abstractions; @@ -36,7 +35,7 @@ public async Task Handle_Html_ReturnsResult() var wrapWithDivParams = new WrapWithTagParams(new() { Uri = uri }) { - Range = VsLspFactory.CreateSingleLineRange(start: (0, 0), length: 2), + Range = LspFactory.CreateSingleLineRange(start: (0, 0), length: 2), }; var requestContext = CreateRazorRequestContext(documentContext); @@ -66,7 +65,7 @@ public async Task Handle_CSharp_ReturnsNull() var wrapWithDivParams = new WrapWithTagParams(new() { Uri = uri }) { - Range = VsLspFactory.CreateSingleLineRange(start: (0, 1), length: 2), + Range = LspFactory.CreateSingleLineRange(start: (0, 1), length: 2), }; var requestContext = CreateRazorRequestContext(documentContext); @@ -97,7 +96,7 @@ public async Task Handle_CSharp_WholeImplicitStatement_ReturnsResult() var wrapWithDivParams = new WrapWithTagParams(new() { Uri = uri }) { - Range = VsLspFactory.CreateSingleLineRange(start: (0, 0), length: 8), + Range = LspFactory.CreateSingleLineRange(start: (0, 0), length: 8), }; var requestContext = CreateRazorRequestContext(documentContext); @@ -163,7 +162,7 @@ public async Task Handle_CSharp_PartOfImplicitStatement_ReturnsNull() var wrapWithDivParams = new WrapWithTagParams(new() { Uri = uri }) { - Range = VsLspFactory.CreateSingleLineRange(line: 0, character: 2, length: 2), + Range = LspFactory.CreateSingleLineRange(line: 0, character: 2, length: 2), }; var requestContext = CreateRazorRequestContext(documentContext); @@ -194,7 +193,7 @@ public async Task Handle_CSharp_InImplicitStatement_ReturnsResult() var wrapWithDivParams = new WrapWithTagParams(new() { Uri = uri }) { - Range = VsLspFactory.CreateZeroWidthRange(0, 4), + Range = LspFactory.CreateZeroWidthRange(0, 4), }; var requestContext = CreateRazorRequestContext(documentContext); @@ -222,7 +221,7 @@ public async Task Handle_DocumentNotFound_ReturnsNull() var wrapWithDivParams = new WrapWithTagParams(new() { Uri = missingUri }) { - Range = VsLspFactory.CreateSingleLineRange(start: (0, 0), length: 2), + Range = LspFactory.CreateSingleLineRange(start: (0, 0), length: 2), }; var requestContext = CreateRazorRequestContext(documentContext: null); @@ -254,7 +253,7 @@ public async Task Handle_UnsupportedCodeDocument_ReturnsNull() var wrapWithDivParams = new WrapWithTagParams(new() { Uri = uri }) { - Range = VsLspFactory.CreateSingleLineRange(start: (0, 0), length: 2), + Range = LspFactory.CreateSingleLineRange(start: (0, 0), length: 2), }; var requestContext = CreateRazorRequestContext(documentContext); @@ -292,10 +291,10 @@ public async Task CleanUpTextEdits_NoTilde() var computedEdits = new TextEdit[] { - VsLspFactory.CreateTextEdit(position: (0, 0), "
" + Environment.NewLine + " "), - VsLspFactory.CreateTextEdit(line: 1, character: 0, " "), - VsLspFactory.CreateTextEdit( - range: VsLspFactory.CreateSingleLineRange(line: 2, character: 0, length: 1), + LspFactory.CreateTextEdit(position: (0, 0), "
" + Environment.NewLine + " "), + LspFactory.CreateTextEdit(line: 1, character: 0, " "), + LspFactory.CreateTextEdit( + range: LspFactory.CreateSingleLineRange(line: 2, character: 0, length: 1), newText: " }" + Environment.NewLine + "
"), }; @@ -331,11 +330,11 @@ public async Task CleanUpTextEdits_BadEditWithTilde() var computedEdits = new TextEdit[] { - VsLspFactory.CreateTextEdit(position: (0, 0), "
" + Environment.NewLine + " "), - VsLspFactory.CreateTextEdit(line: 1, character: 0, " "), + LspFactory.CreateTextEdit(position: (0, 0), "
" + Environment.NewLine + " "), + LspFactory.CreateTextEdit(line: 1, character: 0, " "), // This is the problematic edit.. the close brace has been replaced with a tilde - VsLspFactory.CreateTextEdit( - range: VsLspFactory.CreateSingleLineRange(line: 2, character: 0, length: 1), + LspFactory.CreateTextEdit( + range: LspFactory.CreateSingleLineRange(line: 2, character: 0, length: 1), newText: " ~" + Environment.NewLine + "
") }; @@ -371,11 +370,11 @@ public async Task CleanUpTextEdits_GoodEditWithTilde() var computedEdits = new[] { - VsLspFactory.CreateTextEdit(position: (0, 0), "
" + Environment.NewLine + " "), - VsLspFactory.CreateTextEdit(line: 1, character: 0, " "), + LspFactory.CreateTextEdit(position: (0, 0), "
" + Environment.NewLine + " "), + LspFactory.CreateTextEdit(line: 1, character: 0, " "), // This looks like a bad edit, but the original source document had a tilde - VsLspFactory.CreateTextEdit( - range: VsLspFactory.CreateSingleLineRange(line: 2, character: 0, length: 1), + LspFactory.CreateTextEdit( + range: LspFactory.CreateSingleLineRange(line: 2, character: 0, length: 1), newText: " ~" + Environment.NewLine + "
") }; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/AssertExtensions.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/AssertExtensions.cs index eeab228a043..6cef26d831a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/AssertExtensions.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/AssertExtensions.cs @@ -1,7 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT license. See License.txt in the project root for license information. -using Microsoft.VisualStudio.Text.Adornments; +extern alias RLSP; + +using RLSP::Roslyn.Text.Adornments; using Xunit; namespace Microsoft.AspNetCore.Razor.Test.Common; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormattingService.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormattingService.cs index 7c082b276cc..6cd32ce4efa 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormattingService.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Formatting_NetFx/HtmlFormattingService.cs @@ -11,7 +11,6 @@ using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Composition; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Utilities; using Microsoft.WebTools.Languages.Shared.ContentTypes; @@ -113,7 +112,7 @@ public void Dispose() foreach (var textChange in response.TextChanges) { var span = new TextSpan(textChange.Position, textChange.Length); - var edit = VsLspFactory.CreateTextEdit(sourceText.GetRange(span), textChange.NewText); + var edit = LspFactory.CreateTextEdit(sourceText.GetRange(span), textChange.NewText); edits.Add(edit); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs index 4590a961b7d..f33ff50f018 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Language/IntegrationTests/RazorToolingIntegrationTestBase.cs @@ -20,6 +20,7 @@ using Xunit; using Xunit.Abstractions; using Xunit.Sdk; +using Diagnostic = Microsoft.CodeAnalysis.Diagnostic; namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests; @@ -288,7 +289,7 @@ protected static CompileToAssemblyResult CompileToAssembly(CompileToCSharpResult var diagnostics = compilation .GetDiagnostics() - .Where(d => d.Severity != DiagnosticSeverity.Hidden); + .Where(d => d.Severity != CodeAnalysis.DiagnosticSeverity.Hidden); if (diagnostics.Any() && throwOnFailure) { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServer.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServer.cs index f095947c978..e7712df1027 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServer.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServer.cs @@ -12,10 +12,8 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.VisualStudio.Composition; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Nerdbank.Streams; using StreamJsonRpc; -using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range; namespace Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; @@ -77,9 +75,6 @@ static SystemTextJsonFormatter CreateSystemTextJsonMessageFormatter(AbstractRazo // Roslyn has its own converters since it doesn't use MS.VS.LS.Protocol languageServerFactory.AddJsonConverters(messageFormatter.JsonSerializerOptions); - // In its infinite wisdom, the LSP client has a public method that takes Newtonsoft.Json types, but an internal method that takes System.Text.Json types. - typeof(VSInternalExtensionUtilities).GetMethod("AddVSInternalExtensionConverters", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)!.Invoke(null, [messageFormatter.JsonSerializerOptions]); - return messageFormatter; } @@ -176,7 +171,7 @@ static DidOpenTextDocumentParams CreateDidOpenTextDocumentParams(Uri uri, string }; } - public async Task ReplaceTextAsync(Uri documentUri, params (Range Range, string Text)[] changes) + internal async Task ReplaceTextAsync(Uri documentUri, params (LspRange Range, string Text)[] changes) { var didChangeParams = CreateDidChangeTextDocumentParams( documentUri, @@ -184,7 +179,7 @@ public async Task ReplaceTextAsync(Uri documentUri, params (Range Range, string await ExecuteRequestAsync(Methods.TextDocumentDidChangeName, didChangeParams, _cancellationToken); - static DidChangeTextDocumentParams CreateDidChangeTextDocumentParams(Uri documentUri, ImmutableArray<(Range Range, string Text)> changes) + static DidChangeTextDocumentParams CreateDidChangeTextDocumentParams(Uri documentUri, ImmutableArray<(LspRange Range, string Text)> changes) { var changeEvents = changes.Select(change => new TextDocumentContentChangeEvent { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServerHelpers.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServerHelpers.cs index f49c6ae78d3..07e57ceec27 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServerHelpers.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/CSharpTestLspServerHelpers.cs @@ -18,7 +18,6 @@ using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Composition; -using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs index 266bd9acdc9..2347a1ce214 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs @@ -40,7 +40,7 @@ protected LanguageServerTestBase(ITestOutputHelper testOutput) { SpanMappingService = new ThrowingRazorSpanMappingService(); - SerializerOptions = JsonHelpers.VsLspJsonSerializerOptions; + SerializerOptions = JsonHelpers.JsonSerializerOptions; FilePathService = new LSPFilePathService(TestLanguageServerFeatureOptions.Instance); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestClientCapabilitiesService.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestClientCapabilitiesService.cs index f3dd0cb02d6..56b25ce496f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestClientCapabilitiesService.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestClientCapabilitiesService.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using Microsoft.CodeAnalysis.Razor.Protocol; -using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.AspNetCore.Razor.LanguageServer.Test; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestDocumentContextFactory.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestDocumentContextFactory.cs index 90049c04c1e..743cea2dcec 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestDocumentContextFactory.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestDocumentContextFactory.cs @@ -5,7 +5,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor.ProjectSystem; -using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestRazorSemanticTokensLegendService.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestRazorSemanticTokensLegendService.cs index 95def5825fc..8688dee484c 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestRazorSemanticTokensLegendService.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/TestRazorSemanticTokensLegendService.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using Microsoft.AspNetCore.Razor.LanguageServer.Test; -using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.AspNetCore.Razor.LanguageServer.Semantic; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj index e9f9f637775..4498b9de54b 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj @@ -17,6 +17,7 @@ + diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListCacheTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListCacheTest.cs index 09d4ddcd119..9ca74f799fb 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListCacheTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListCacheTest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using Microsoft.AspNetCore.Razor.Test.Common; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListMergerTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListMergerTest.cs index 6fe44aad1d8..2e83e3c19bb 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListMergerTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListMergerTest.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Razor.Test.Common; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListOptimizerTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListOptimizerTest.cs index bc41b1ed2c9..7b99d5e7943 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListOptimizerTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/CompletionListOptimizerTest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using Microsoft.AspNetCore.Razor.Test.Common; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/DirectiveVerifier.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/DirectiveVerifier.cs index 739d4643232..44e50eabd62 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/DirectiveVerifier.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/DirectiveVerifier.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; namespace Microsoft.CodeAnalysis.Razor.Completion; diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/RazorCompletionListProviderTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/RazorCompletionListProviderTest.cs index 31e14e2fd1b..0378fac5a65 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/RazorCompletionListProviderTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/RazorCompletionListProviderTest.cs @@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.CodeAnalysis.Razor.Tooltip; using Microsoft.CodeAnalysis.Testing; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Hover/HoverFactoryTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Hover/HoverFactoryTest.cs index fae68d11ec6..ae21d6dbd18 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Hover/HoverFactoryTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Hover/HoverFactoryTest.cs @@ -8,8 +8,7 @@ using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.Razor.Tooltip; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.Text.Adornments; +using Roslyn.Text.Adornments; using Moq; using Xunit; using Xunit.Abstractions; @@ -48,9 +47,8 @@ public async Task GetHoverAsync_TagHelper_Element() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**Test1TagHelper**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); Assert.Equal(expectedRange, hover.Range); } @@ -72,9 +70,8 @@ public async Task GetHoverAsync_TagHelper_Element_WithParent() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**SomeChild**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 2, character: 5, length: 9); + var expectedRange = LspFactory.CreateSingleLineRange(line: 2, character: 5, length: 9); Assert.Equal(expectedRange, hover.Range); } @@ -96,7 +93,6 @@ public async Task GetHoverAsync_TagHelper_Attribute_WithParent() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**Attribute**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); var expectedRange = codeDocument.Source.Text.GetRange(code.Span); Assert.Equal(expectedRange, hover.Range); @@ -118,9 +114,8 @@ public async Task GetHoverAsync_TagHelper_Element_EndTag() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**Test1TagHelper**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 9, length: 5); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 9, length: 5); Assert.Equal(expectedRange, hover.Range); } @@ -140,10 +135,9 @@ public async Task GetHoverAsync_TagHelper_Attribute() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**BoolVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.DoesNotContain("**IntVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); Assert.Equal(expectedRange, hover.Range); } @@ -163,10 +157,9 @@ public async Task GetHoverAsync_TagHelper_AttributeTrailingEdge() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**BoolVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.DoesNotContain("**IntVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); Assert.Equal(expectedRange, hover.Range); } @@ -240,10 +233,9 @@ public async Task GetHoverAsync_TagHelper_MinimizedAttribute() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**BoolVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.DoesNotContain("**IntVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); Assert.Equal(expectedRange, hover.Range); } @@ -267,9 +259,8 @@ public void Increment(){ // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**Test**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 5, length: 5); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 5, length: 5); Assert.Equal(expectedRange, hover.Range); } @@ -289,9 +280,8 @@ public async Task GetHoverAsync_TagHelper_MalformedElement() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**Test1TagHelper**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); Assert.Equal(expectedRange, hover.Range); } @@ -311,10 +301,9 @@ public async Task GetHoverAsync_TagHelper_MalformedAttribute() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("**BoolVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.DoesNotContain("**IntVal**", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); Assert.Equal(expectedRange, hover.Range); } @@ -352,10 +341,9 @@ public async Task GetHoverAsync_TagHelper_PlainTextElement() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("Test1TagHelper", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.Equal(MarkupKind.PlainText, ((MarkupContent)hover.Contents).Kind); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); Assert.Equal(expectedRange, hover.Range); } @@ -375,10 +363,9 @@ public async Task GetHoverAsync_TagHelper_PlainTextElement_EndTag() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("Test1TagHelper", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.Equal(MarkupKind.PlainText, ((MarkupContent)hover.Contents).Kind); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 9, length: 5); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 9, length: 5); Assert.Equal(expectedRange, hover.Range); } @@ -397,10 +384,9 @@ public async Task GetHoverAsync_TagHelper_TextComponent() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("Text", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.Equal(MarkupKind.PlainText, ((MarkupContent)hover.Contents).Kind); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 0, character: 1, length: 4); + var expectedRange = LspFactory.CreateSingleLineRange(line: 0, character: 1, length: 4); Assert.Equal(expectedRange, hover.Range); } @@ -421,10 +407,9 @@ public async Task GetHoverAsync_TagHelper_TextComponent_NestedInHtml() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("Text", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.Equal(MarkupKind.PlainText, ((MarkupContent)hover.Contents).Kind); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 5, length: 4); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 5, length: 4); Assert.Equal(expectedRange, hover.Range); } @@ -468,10 +453,9 @@ public async Task GetHoverAsync_TagHelper_TextComponent_NestedInCSharpAndText() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("Text", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.Equal(MarkupKind.PlainText, ((MarkupContent)hover.Contents).Kind); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 3, character: 9, length: 4); + var expectedRange = LspFactory.CreateSingleLineRange(line: 3, character: 9, length: 4); Assert.Equal(expectedRange, hover.Range); } @@ -491,11 +475,10 @@ public async Task GetHoverAsync_TagHelper_PlainTextAttribute() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); Assert.Contains("BoolVal", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.DoesNotContain("IntVal", ((MarkupContent)hover.Contents).Value, StringComparison.Ordinal); Assert.Equal(MarkupKind.PlainText, ((MarkupContent)hover.Contents).Kind); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); Assert.Equal(expectedRange, hover.Range); } @@ -551,10 +534,9 @@ public async Task GetHoverAsync_TagHelper_Element_VSClient_ReturnVSHover() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); - Assert.False(hover.Contents.Value.TryGetFourth(out var _)); - Assert.True(hover.Contents.Value.TryGetThird(out var _) && !hover.Contents.Value.Third.Any()); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); + Assert.False(hover.Contents.TryGetFourth(out var _)); + Assert.True(hover.Contents.TryGetThird(out var _) && !hover.Contents.Third.Any()); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5); Assert.Equal(expectedRange, hover.Range); var vsHover = Assert.IsType(hover); @@ -589,10 +571,9 @@ public async Task GetHoverAsync_TagHelper_Attribute_VSClient_ReturnVSHover() // Assert Assert.NotNull(hover); - Assert.NotNull(hover.Contents); - Assert.False(hover.Contents.Value.TryGetFourth(out _)); - Assert.True(hover.Contents.Value.TryGetThird(out var markedStrings) && !markedStrings.Any()); - var expectedRange = VsLspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); + Assert.False(hover.Contents.TryGetFourth(out _)); + Assert.True(hover.Contents.TryGetThird(out var markedStrings) && !markedStrings.Any()); + var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 7, length: 8); Assert.Equal(expectedRange, hover.Range); var vsHover = Assert.IsType(hover); diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj index 36c2f7e6ac4..71aca3c9824 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Microsoft.CodeAnalysis.Razor.Workspaces.Test.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ClassifiedTagHelperTooltipFactoryTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ClassifiedTagHelperTooltipFactoryTest.cs index eb7f49dd11a..b04f9d4a0f0 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ClassifiedTagHelperTooltipFactoryTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ClassifiedTagHelperTooltipFactoryTest.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Classification; -using Microsoft.VisualStudio.Text.Adornments; +using Roslyn.Text.Adornments; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/MarkupTagHelperTooltipFactoryTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/MarkupTagHelperTooltipFactoryTest.cs index b0c37f88f75..4af34838900 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/MarkupTagHelperTooltipFactoryTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/MarkupTagHelperTooltipFactoryTest.cs @@ -6,7 +6,6 @@ using System.Collections.Immutable; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Test.Common; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CohostCodeActionsEndpointTestBase.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CohostCodeActionsEndpointTestBase.cs index 4df101a158c..618212adab9 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CohostCodeActionsEndpointTestBase.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CohostCodeActionsEndpointTestBase.cs @@ -19,12 +19,10 @@ using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Remote.Razor; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Razor.Settings; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; @@ -170,11 +168,11 @@ private async Task VerifyCodeActionResultAsync(TextDocument document, WorkspaceE var text = await textDocument.GetTextAsync(DisposalToken).ConfigureAwait(false); if (textDocument is Document) { - solution = solution.WithDocumentText(textDocument.Id, text.WithChanges(edit.Edits.Select(text.GetTextChange))); + solution = solution.WithDocumentText(textDocument.Id, text.WithChanges(edit.Edits.Select(e => text.GetTextChange((TextEdit)e)))); } else { - solution = solution.WithAdditionalDocumentText(textDocument.Id, text.WithChanges(edit.Edits.Select(text.GetTextChange))); + solution = solution.WithAdditionalDocumentText(textDocument.Id, text.WithChanges(edit.Edits.Select(e => text.GetTextChange((TextEdit)e)))); } } diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentCompletionEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentCompletionEndpointTest.cs index 9f9dfac1b9b..ffadd610c33 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentCompletionEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentCompletionEndpointTest.cs @@ -11,18 +11,11 @@ using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Razor.Completion; using Microsoft.CodeAnalysis.Razor.Settings; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.ProjectSystem; using Microsoft.VisualStudio.Razor.Settings; using Microsoft.VisualStudio.Razor.Snippets; using Xunit; using Xunit.Abstractions; -using RoslynCompletionParams = Roslyn.LanguageServer.Protocol.CompletionParams; -using RoslynCompletionTriggerKind = Roslyn.LanguageServer.Protocol.CompletionTriggerKind; -using RoslynLspExtensions = Roslyn.LanguageServer.Protocol.RoslynLspExtensions; -using RoslynTextDocumentIdentifier = Roslyn.LanguageServer.Protocol.TextDocumentIdentifier; -using RoslynVSInternalCompletionContext = Roslyn.LanguageServer.Protocol.VSInternalCompletionContext; -using RoslynVSInternalCompletionInvokeKind = Roslyn.LanguageServer.Protocol.VSInternalCompletionInvokeKind; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; @@ -41,10 +34,10 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Explicit, - TriggerKind = RoslynCompletionTriggerKind.Invoked + InvokeKind = VSInternalCompletionInvokeKind.Explicit, + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["var", "char", "DateTime", "Exception"]); } @@ -60,11 +53,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "@", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["char", "DateTime", "Exception"]); } @@ -80,11 +73,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = ".", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["DaysInMonth", "IsLeapYear", "Now"]); } @@ -102,11 +95,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Explicit, + InvokeKind = VSInternalCompletionInvokeKind.Explicit, TriggerCharacter = null, - TriggerKind = RoslynCompletionTriggerKind.Invoked + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["char", "DateTime", "Exception"]); } @@ -129,11 +122,11 @@ void foo() The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = ".", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["DaysInMonth", "IsLeapYear", "Now"]); } @@ -151,11 +144,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Explicit, + InvokeKind = VSInternalCompletionInvokeKind.Explicit, TriggerCharacter = null, - TriggerKind = RoslynCompletionTriggerKind.Invoked + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["Equals(object? obj)", "GetHashCode()", "SetParametersAsync(ParameterView parameters)", "ToString()"]); } @@ -179,11 +172,11 @@ void foo() The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "<", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["text", "EditForm", "InputDate", "div"], delegatedItemLabels: ["div"]); @@ -220,11 +213,11 @@ void foo() The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "@", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: expectedLabels); } @@ -240,11 +233,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "<", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["LayoutView", "EditForm", "ValidationMessage", "div"], delegatedItemLabels: ["div"]); @@ -261,11 +254,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "<", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["div", "h1", "LayoutView", "EditForm", "ValidationMessage"], delegatedItemLabels: ["div", "h1"]); @@ -280,11 +273,11 @@ This is a Razor document. <$$ """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "<", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["div", "h1", "LayoutView", "EditForm", "ValidationMessage"], delegatedItemLabels: ["div", "h1"], @@ -302,11 +295,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "<", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["div", "h1", "LayoutView", "EditForm", "ValidationMessage"], delegatedItemLabels: ["div", "h1"], @@ -325,11 +318,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Explicit, + InvokeKind = VSInternalCompletionInvokeKind.Explicit, TriggerCharacter = null, - TriggerKind = RoslynCompletionTriggerKind.Invoked + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["snippet1", "snippet2"], delegatedItemLabels: [], @@ -343,11 +336,11 @@ await VerifyCompletionListAsync( input: """ $$ """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Explicit, + InvokeKind = VSInternalCompletionInvokeKind.Explicit, TriggerCharacter = null, - TriggerKind = RoslynCompletionTriggerKind.Invoked + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["snippet1", "snippet2"], delegatedItemLabels: [], @@ -362,11 +355,11 @@ await VerifyCompletionListAsync( $$ """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Explicit, + InvokeKind = VSInternalCompletionInvokeKind.Explicit, TriggerCharacter = null, - TriggerKind = RoslynCompletionTriggerKind.Invoked + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["snippet1", "snippet2"], delegatedItemLabels: [], @@ -381,11 +374,11 @@ await VerifyCompletionListAsync( $$ """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Explicit, + InvokeKind = VSInternalCompletionInvokeKind.Explicit, TriggerCharacter = null, - TriggerKind = RoslynCompletionTriggerKind.Invoked + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["snippet1", "snippet2"], delegatedItemLabels: [], @@ -403,11 +396,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = " ", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["style", "dir"], unexpectedItemLabels: ["snippet1", "snippet2"], @@ -427,11 +420,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = " ", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["style", "dir", "@..."], delegatedItemLabels: ["style", "dir"]); @@ -449,11 +442,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = "@", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["style", "dir", "@rendermode", "@bind-..."], delegatedItemLabels: ["style", "dir"]); @@ -471,11 +464,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = null, - TriggerKind = RoslynCompletionTriggerKind.Invoked + TriggerKind = CompletionTriggerKind.Invoked }, expectedItemLabels: ["style", "dir", "culture", "event", "format", "get", "set", "after"], delegatedItemLabels: ["style", "dir"]); @@ -492,11 +485,11 @@ This is a Razor document. The end. """, - completionContext: new RoslynVSInternalCompletionContext() + completionContext: new VSInternalCompletionContext() { - InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing, + InvokeKind = VSInternalCompletionInvokeKind.Typing, TriggerCharacter = " ", - TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter + TriggerKind = CompletionTriggerKind.TriggerCharacter }, expectedItemLabels: ["style", "dir", "FormName", "OnValidSubmit", "@..."], delegatedItemLabels: ["style", "dir"]); @@ -511,11 +504,11 @@ This is a Razor document. ClientNotifyAsync public Task RequestAsync(ITextBuffer textBuffer, Func capabilitiesFilter, string languageServerName, string method, Func parameterFactory, CancellationToken cancellationToken) => throw new NotImplementedException(); public Task RequestAsync(ILanguageClient languageClient, string method, JToken parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); public Task RequestAsync(Request request, CancellationToken cancellationToken) => throw new NotImplementedException(); - public Task<(ILanguageClient?, TOut)> RequestAsync(string[] contentTypes, Func capabilitiesFilter, LspRequest method, TIn parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); - public Task RequestAsync(ILanguageClient languageClient, LspRequest method, TIn parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task<(ILanguageClient?, TOut)> RequestAsync(string[] contentTypes, Func capabilitiesFilter, VSLSP.LspRequest method, TIn parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task RequestAsync(ILanguageClient languageClient, VSLSP.LspRequest method, TIn parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); public Task> RequestMultipleAsync(string[] contentTypes, Func capabilitiesFilter, string method, JToken parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); public IAsyncEnumerable RequestMultipleAsync(ITextBuffer textBuffer, Func capabilitiesFilter, string method, Func parameterFactory, CancellationToken cancellationToken) => throw new NotImplementedException(); - public Task> RequestMultipleAsync(string[] contentTypes, Func capabilitiesFilter, LspRequest method, TIn parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task> RequestMultipleAsync(string[] contentTypes, Func capabilitiesFilter, VSLSP.LspRequest method, TIn parameters, CancellationToken cancellationToken) => throw new NotImplementedException(); } [Export(typeof(IWorkspaceProvider))] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs index c1fd7478cb2..b392bc54131 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTestBase.cs @@ -23,9 +23,8 @@ using Microsoft.CodeAnalysis.Text; using Microsoft.NET.Sdk.Razor.SourceGenerators; using Microsoft.VisualStudio.Composition; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Xunit; using Roslyn.Test.Utilities; +using Xunit; using Xunit.Abstractions; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFindAllReferencesEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFindAllReferencesEndpointTest.cs index 80011167cd7..e87ee65657f 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFindAllReferencesEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFindAllReferencesEndpointTest.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Razor.Utilities; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Text; -using Roslyn.LanguageServer.Protocol; using Roslyn.Text.Adornments; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFoldingRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFoldingRangeEndpointTest.cs index 6af5a045c67..2dcb667c79a 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFoldingRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFoldingRangeEndpointTest.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToDefinitionEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToDefinitionEndpointTest.cs index 1bfd5c1165d..24666f4b1a7 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToDefinitionEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToDefinitionEndpointTest.cs @@ -9,12 +9,8 @@ using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; -using RoslynDocumentLink = Roslyn.LanguageServer.Protocol.DocumentLink; -using RoslynLocation = Roslyn.LanguageServer.Protocol.Location; -using RoslynLspExtensions = Roslyn.LanguageServer.Protocol.RoslynLspExtensions; using TextDocument = Microsoft.CodeAnalysis.TextDocument; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; @@ -153,7 +149,7 @@ public async Task Component() var location = Assert.Single(locations); var text = SourceText.From(surveyPrompt.Text); - var range = RoslynLspExtensions.GetRange(text, surveyPrompt.Span); + var range = text.GetRange(surveyPrompt.Span); Assert.Equal(range, location.Range); } @@ -199,7 +195,7 @@ @namespace SomeProject var location = Assert.Single(locations); var text = SourceText.From(surveyPrompt.Text); - var range = RoslynLspExtensions.GetRange(text, surveyPrompt.Span); + var range = text.GetRange(surveyPrompt.Span); Assert.Equal(range, location.Range); } @@ -250,13 +246,13 @@ private async Task VerifyGoToDefinitionAsync(TestCode input, string? fileKind = var location = Assert.Single(locations); var text = SourceText.From(input.Text); - var range = RoslynLspExtensions.GetRange(text, input.Span); + var range = text.GetRange(input.Span); Assert.Equal(range, location.Range); Assert.Equal(document.CreateUri(), location.Uri); } - private async Task?> GetGoToDefinitionResultAsync( + private async Task?> GetGoToDefinitionResultAsync( TestCode input, string? fileKind = null, params (string fileName, string contents)[]? additionalFiles) { UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); @@ -265,7 +261,7 @@ private async Task VerifyGoToDefinitionAsync(TestCode input, string? fileKind = return await GetGoToDefinitionResultCoreAsync(document, input, htmlResponse: null); } - private async Task?> GetGoToDefinitionResultCoreAsync( + private async Task?> GetGoToDefinitionResultCoreAsync( TextDocument document, TestCode input, SumType? htmlResponse) { var inputText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs index 6db852ad742..0b5849367d5 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs @@ -9,11 +9,8 @@ using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Remote.Razor; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; -using LspLocation = Microsoft.VisualStudio.LanguageServer.Protocol.Location; -using RoslynLspExtensions = Roslyn.LanguageServer.Protocol.RoslynLspExtensions; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; @@ -154,19 +151,11 @@ private async Task VerifyGoToImplementationResultCoreAsync(TestCode input, TextD if (result.Value.TryGetFirst(out var roslynLocations)) { var expected = input.Spans.Select(s => inputText.GetRange(s).ToLinePositionSpan()).OrderBy(r => r.Start.Line).ToArray(); - var actual = roslynLocations.Select(l => RoslynLspExtensions.ToLinePositionSpan(l.Range)).OrderBy(r => r.Start.Line).ToArray(); + var actual = roslynLocations.Select(l => l.Range.ToLinePositionSpan()).OrderBy(r => r.Start.Line).ToArray(); Assert.Equal(expected, actual); Assert.All(roslynLocations, l => l.Uri.Equals(document.CreateUri())); } - else if (result.Value.TryGetSecond(out var vsLocations)) - { - var expected = input.Spans.Select(s => inputText.GetRange(s).ToLinePositionSpan()).OrderBy(r => r.Start.Line).ToArray(); - var actual = vsLocations.Select(l => l.Range.ToLinePositionSpan()).OrderBy(r => r.Start.Line).ToArray(); - Assert.Equal(expected, actual); - - Assert.All(vsLocations, l => l.Uri.Equals(document.CreateUri())); - } else { Assert.Fail($"Unsupported result type: {result.Value.GetType()}"); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostHoverEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostHoverEndpointTest.cs index 068e3ce8b96..c0951e01a7d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostHoverEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostHoverEndpointTest.cs @@ -7,10 +7,8 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; -using RoslynHover = Roslyn.LanguageServer.Protocol.Hover; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; @@ -183,7 +181,7 @@ await VerifyHoverAsync(code, async (hover, document) => }); } - private async Task VerifyHoverAsync(TestCode input, Func verifyHover) + private async Task VerifyHoverAsync(TestCode input, Func verifyHover) { UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); @@ -191,10 +189,7 @@ private async Task VerifyHoverAsync(TestCode input, Func verifyHover) @@ -205,13 +200,10 @@ private async Task VerifyHoverAsync(TestCode input, Hover htmlResponse, Action?> GetHoverResultAsync(TextDocument document, TestCode input, Hover? htmlResponse = null) + private async Task GetHoverResultAsync(TextDocument document, TestCode input, Hover? htmlResponse = null) { var inputText = await document.GetTextAsync(DisposalToken); var linePosition = inputText.GetLinePosition(input.Position); @@ -221,7 +213,7 @@ private async Task VerifyHoverAsync(TestCode input, Hover htmlResponse, Action() + new Dictionary() { [hostDocumentPosition] = hostBreakpointRange }); @@ -187,6 +185,6 @@ private static Position GetPosition(string content, ITextBuffer textBuffer) } var line = textBuffer.CurrentSnapshot.GetLineFromPosition(index); - return VsLspFactory.CreatePosition(line.LineNumber, index - line.Start.Position); + return LspFactory.CreatePosition(line.LineNumber, index - line.Start.Position); } } diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/RazorProximityExpressionResolverTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/RazorProximityExpressionResolverTest.cs index 7c15ab02144..b3129ae4af9 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/RazorProximityExpressionResolverTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/RazorProximityExpressionResolverTest.cs @@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Razor.Threading; using Microsoft.CodeAnalysis.Razor.Remote; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Razor.Debugging; using Microsoft.VisualStudio.Text; using Moq; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/TestLSPBreakpointSpanProvider.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/TestLSPBreakpointSpanProvider.cs index dc7e3527557..5b72eabae2e 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/TestLSPBreakpointSpanProvider.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/Debugging/TestLSPBreakpointSpanProvider.cs @@ -10,17 +10,15 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Threading; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range; namespace Microsoft.VisualStudio.Razor.LanguageClient.Debugging; internal class TestLSPBreakpointSpanProvider : ILSPBreakpointSpanProvider { private readonly Uri _documentUri; - private readonly IReadOnlyDictionary _mappings; + private readonly IReadOnlyDictionary _mappings; - public TestLSPBreakpointSpanProvider(Uri documentUri, IReadOnlyDictionary mappings) + public TestLSPBreakpointSpanProvider(Uri documentUri, IReadOnlyDictionary mappings) { if (documentUri is null) { @@ -36,11 +34,11 @@ public TestLSPBreakpointSpanProvider(Uri documentUri, IReadOnlyDictionary GetBreakpointSpanAsync(LSPDocumentSnapshot documentSnapshot, long hostDocumentSyncVersion, Position position, CancellationToken cancellationToken) + public Task GetBreakpointSpanAsync(LSPDocumentSnapshot documentSnapshot, long hostDocumentSyncVersion, Position position, CancellationToken cancellationToken) { if (documentSnapshot.Uri != _documentUri) { - return SpecializedTasks.Null(); + return SpecializedTasks.Null(); } foreach (var mapping in _mappings.OrderBy(d => d.Key)) @@ -52,6 +50,6 @@ public Task GetBreakpointSpanAsync(LSPDocumentSnapshot documentSnapshot, } } - return SpecializedTasks.Null(); + return SpecializedTasks.Null(); } } diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DocumentMapping/LSPDocumentMappingProviderTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DocumentMapping/LSPDocumentMappingProviderTest.cs index c13654a7879..bd942f66daa 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DocumentMapping/LSPDocumentMappingProviderTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DocumentMapping/LSPDocumentMappingProviderTest.cs @@ -11,7 +11,6 @@ using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Razor.Protocol.DocumentMapping; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Text; using Moq; using Xunit; @@ -47,7 +46,7 @@ public async Task RazorMapToDocumentRangeAsync_InvokesLanguageServer() var response = new RazorMapToDocumentRangesResponse() { - Ranges = [VsLspFactory.CreateRange(1, 1, 3, 3)], + Ranges = [LspFactory.CreateRange(1, 1, 3, 3)], HostDocumentVersion = 1 }; var requestInvoker = new Mock(MockBehavior.Strict); @@ -61,7 +60,7 @@ public async Task RazorMapToDocumentRangeAsync_InvokesLanguageServer() .ReturnsAsync(new ReinvocationResponse("TestLanguageClient", response)); var mappingProvider = new LSPDocumentMappingProvider(requestInvoker.Object, _documentManager); - var projectedRange = VsLspFactory.CreateRange(10, 10, 15, 15); + var projectedRange = LspFactory.CreateRange(10, 10, 15, 15); // Act var result = await mappingProvider.MapToDocumentRangesAsync(RazorLanguageKind.CSharp, uri, new[] { projectedRange }, DisposalToken); @@ -70,7 +69,7 @@ public async Task RazorMapToDocumentRangeAsync_InvokesLanguageServer() Assert.NotNull(result); Assert.Equal(1, result.HostDocumentVersion); var actualRange = result.Ranges[0]; - Assert.Equal(VsLspFactory.CreatePosition(1, 1), actualRange.Start); - Assert.Equal(VsLspFactory.CreatePosition(3, 3), actualRange.End); + Assert.Equal(LspFactory.CreatePosition(1, 1), actualRange.Start); + Assert.Equal(LspFactory.CreatePosition(3, 3), actualRange.End); } } diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorCustomMessageTargetTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorCustomMessageTargetTest.cs index b1421041384..b85cb0209ad 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorCustomMessageTargetTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorCustomMessageTargetTest.cs @@ -18,7 +18,6 @@ using Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Razor.LanguageClient.Cohost; using Microsoft.VisualStudio.Razor.Settings; using Microsoft.VisualStudio.Razor.Snippets; @@ -223,7 +222,7 @@ public async Task ProvideCodeActionsAsync_CannotLookupDocument_ReturnsNullAsync( { Uri = new Uri("C:/path/to/file.razor") }, - Range = VsLspFactory.DefaultRange, + Range = LspFactory.DefaultRange, Context = new VSInternalCodeActionContext() } }; @@ -306,7 +305,7 @@ async IAsyncEnumerable> { Uri = testDocUri }, - Range = VsLspFactory.DefaultRange, + Range = LspFactory.DefaultRange, Context = new VSInternalCodeActionContext() } }; @@ -431,7 +430,7 @@ public async Task ProvideSemanticTokensAsync_CannotLookupDocument_ReturnsNullAsy Uri = new Uri("C:/path/to/file.razor") }, requiredHostDocumentVersion: 1, - ranges: [VsLspFactory.DefaultRange], + ranges: [LspFactory.DefaultRange], correlationId: Guid.Empty); // Act @@ -480,7 +479,7 @@ public async Task ProvideSemanticTokensAsync_CannotLookupVirtualDocument_Returns Uri = new Uri("C:/path/to/file.razor") }, requiredHostDocumentVersion: 0, - ranges: [VsLspFactory.DefaultRange], + ranges: [LspFactory.DefaultRange], correlationId: Guid.Empty); // Act @@ -515,11 +514,11 @@ public async Task ProvideSemanticTokensAsync_ContainsRange_ReturnsSemanticTokens var expectedCSharpResults = new SemanticTokens() { Data = new int[] { It.IsAny() } }; var requestInvoker = new Mock(MockBehavior.Strict); requestInvoker - .Setup(invoker => invoker.ReinvokeRequestOnServerAsync( + .Setup(invoker => invoker.ReinvokeRequestOnServerAsync( _textBuffer, It.IsAny(), RazorLSPConstants.RazorCSharpLanguageServerName, - It.IsAny(), + It.IsAny(), It.IsAny())) .ReturnsAsync(new ReinvocationResponse("languageClient", expectedCSharpResults)); @@ -562,7 +561,7 @@ public async Task ProvideSemanticTokensAsync_ContainsRange_ReturnsSemanticTokens Uri = new Uri("C:/path/to%20-%20project/file.razor") }, requiredHostDocumentVersion: 0, - ranges: [VsLspFactory.DefaultRange], + ranges: [LspFactory.DefaultRange], correlationId: Guid.Empty); // Act @@ -598,11 +597,11 @@ public async Task ProvideSemanticTokensAsync_EmptyRange_ReturnsNoSemanticTokens( var expectedCSharpResults = new SemanticTokens(); var requestInvoker = new Mock(MockBehavior.Strict); requestInvoker - .Setup(invoker => invoker.ReinvokeRequestOnServerAsync( + .Setup(invoker => invoker.ReinvokeRequestOnServerAsync( _textBuffer, It.IsAny(), RazorLSPConstants.RazorCSharpLanguageServerName, - It.IsAny(), + It.IsAny(), It.IsAny())) .ReturnsAsync(new ReinvocationResponse("languageClient", expectedCSharpResults)); @@ -645,7 +644,7 @@ public async Task ProvideSemanticTokensAsync_EmptyRange_ReturnsNoSemanticTokens( Uri = new Uri("C:/path/to%20-%20project/file.razor") }, requiredHostDocumentVersion: 0, - ranges: [VsLspFactory.DefaultRange], + ranges: [LspFactory.DefaultRange], correlationId: Guid.Empty); var expectedResults = new ProvideSemanticTokensResponse(null, documentVersion); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs index df65c78c417..4b5f6214c76 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.AspNetCore.Razor.Utilities; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Settings; @@ -17,6 +16,7 @@ using Microsoft.VisualStudio.Razor.Settings; using Xunit; using Xunit.Abstractions; +using FormattingOptions = Microsoft.CodeAnalysis.Formatting.FormattingOptions; namespace Microsoft.VisualStudio.Razor.LanguageClient; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPMappingServiceTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPMappingServiceTest.cs index c246a768acf..c7bb4e7029c 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPMappingServiceTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPMappingServiceTest.cs @@ -10,11 +10,9 @@ using Microsoft.CodeAnalysis.Razor.Protocol.DocumentMapping; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Razor.LanguageClient.DocumentMapping; using Xunit; using Xunit.Abstractions; -using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range; namespace Microsoft.VisualStudio.Razor.LanguageClient; @@ -22,13 +20,13 @@ public class RazorLSPMappingServiceTest(ITestOutputHelper testOutput) : ToolingT { private readonly Uri _mockDocumentUri = new("C://project/path/document.razor"); - const string s_mockGeneratedContent = """ + private const string MockGeneratedContent = """ Hello This is the source text in the generated C# file. This is some more sample text for demo purposes. """; - const string s_mockRazorContent = """ + private const string MockRazorContent = """ Hello This is the source text @@ -36,8 +34,8 @@ in the generated C# file. This is some more sample text for demo purposes. """; - private static readonly SourceText _sourceTextGenerated = SourceText.From(s_mockGeneratedContent); - private static readonly SourceText _sourceTextRazor = SourceText.From(s_mockRazorContent); + private static readonly SourceText s_sourceTextGenerated = SourceText.From(MockGeneratedContent); + private static readonly SourceText s_sourceTextRazor = SourceText.From(MockRazorContent); [Fact] public async Task MapSpans_WithinRange_ReturnsMapping() @@ -48,12 +46,12 @@ public async Task MapSpans_WithinRange_ReturnsMapping() var documentSnapshot = new StrictMock(); documentSnapshot.SetupGet(doc => doc.Uri).Returns(_mockDocumentUri); - documentSnapshot.SetupGet(doc => doc.Snapshot).Returns(new StringTextSnapshot(_sourceTextRazor.ToString())); + documentSnapshot.SetupGet(doc => doc.Snapshot).Returns(new StringTextSnapshot(s_sourceTextRazor.ToString())); - var textSnapshot = new StringTextSnapshot(s_mockGeneratedContent, 1); + var textSnapshot = new StringTextSnapshot(MockGeneratedContent, 1); - var textSpanAsRange = _sourceTextGenerated.GetRange(textSpan); - var mappedRange = VsLspFactory.CreateSingleLineRange(2, character: 1, length: 10); + var textSpanAsRange = s_sourceTextGenerated.GetRange(textSpan); + var mappedRange = LspFactory.CreateSingleLineRange(2, character: 1, length: 10); var mappingResult = new RazorMapToDocumentRangesResponse() { @@ -76,13 +74,13 @@ public async Task MapSpans_WithinRange_ReturnsMapping() var service = new RazorLSPMappingService(documentMappingProvider, documentSnapshot.Object, textSnapshot); - var expectedSpan = _sourceTextRazor.GetTextSpan(mappedRange); - var expectedLinePosition = _sourceTextRazor.GetLinePositionSpan(expectedSpan); + var expectedSpan = s_sourceTextRazor.GetTextSpan(mappedRange); + var expectedLinePosition = s_sourceTextRazor.GetLinePositionSpan(expectedSpan); var expectedFilePath = _mockDocumentUri.LocalPath; var expectedResult = (expectedFilePath, expectedLinePosition, expectedSpan); // Act - var result = await service.GetTestAccessor().MapSpansAsync(spans, _sourceTextGenerated, _sourceTextRazor, DisposalToken); + var result = await service.GetTestAccessor().MapSpansAsync(spans, s_sourceTextGenerated, s_sourceTextRazor, DisposalToken); // Assert Assert.Single(result, expectedResult); @@ -97,11 +95,11 @@ public async Task MapSpans_OutsideRange_ReturnsEmpty() var documentSnapshot = new StrictMock(); documentSnapshot.SetupGet(doc => doc.Uri).Returns(_mockDocumentUri); - documentSnapshot.SetupGet(doc => doc.Snapshot).Returns(new StringTextSnapshot(_sourceTextRazor.ToString())); + documentSnapshot.SetupGet(doc => doc.Snapshot).Returns(new StringTextSnapshot(s_sourceTextRazor.ToString())); - var textSnapshot = new StringTextSnapshot(s_mockGeneratedContent, 1); + var textSnapshot = new StringTextSnapshot(MockGeneratedContent, 1); - var textSpanAsRange = _sourceTextGenerated.GetRange(textSpan); + var textSpanAsRange = s_sourceTextGenerated.GetRange(textSpan); var requestInvoker = new TestLSPRequestInvoker(new List<(string, object?)>() { @@ -121,7 +119,7 @@ public async Task MapSpans_OutsideRange_ReturnsEmpty() var service = new RazorLSPMappingService(documentMappingProvider, documentSnapshot.Object, textSnapshot); // Act - var result = await service.GetTestAccessor().MapSpansAsync(spans, _sourceTextGenerated, _sourceTextRazor, DisposalToken); + var result = await service.GetTestAccessor().MapSpansAsync(spans, s_sourceTextGenerated, s_sourceTextRazor, DisposalToken); // Assert Assert.Empty(result); @@ -132,7 +130,7 @@ public void MapSpans_GetMappedSpanResults_MappingErrorReturnsDefaultMappedSpan() { // Arrange var sourceTextRazor = SourceText.From(""); - var response = new RazorMapToDocumentRangesResponse { Ranges = new Range[] { VsLspFactory.UndefinedRange } }; + var response = new RazorMapToDocumentRangesResponse { Ranges = [LspFactory.UndefinedRange] }; // Act var results = RazorLSPSpanMappingService.GetMappedSpanResults(_mockDocumentUri.LocalPath, sourceTextRazor, response); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPSpanMappingServiceTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPSpanMappingServiceTest.cs index d54401df24d..a5bfb4e5de1 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPSpanMappingServiceTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorLSPSpanMappingServiceTest.cs @@ -3,22 +3,17 @@ using System; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.Editor; -using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Razor.Protocol.DocumentMapping; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Razor.LanguageClient.DocumentMapping; -using Microsoft.VisualStudio.Text; using Moq; using Xunit; using Xunit.Abstractions; -using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range; namespace Microsoft.VisualStudio.Razor.LanguageClient; @@ -26,12 +21,12 @@ public class RazorLSPSpanMappingServiceTest(ITestOutputHelper testOutput) : Tool { private readonly Uri _mockDocumentUri = new("C://project/path/document.razor"); - const string s_mockGeneratedContent = """ + private const string MockGeneratedContent = """ Hello This is the source text in the generated C# file. This is some more sample text for demo purposes. """; - const string s_mockRazorContent = """ + private const string MockRazorContent = """ Hello This is the source text @@ -39,8 +34,8 @@ in the generated C# file. This is some more sample text for demo purposes. """; - private static readonly SourceText _sourceTextGenerated = SourceText.From(s_mockGeneratedContent); - private static readonly SourceText _sourceTextRazor = SourceText.From(s_mockRazorContent); + private static readonly SourceText s_sourceTextGenerated = SourceText.From(MockGeneratedContent); + private static readonly SourceText s_sourceTextRazor = SourceText.From(MockRazorContent); [Fact] public async Task MapSpans_WithinRange_ReturnsMapping() @@ -52,10 +47,10 @@ public async Task MapSpans_WithinRange_ReturnsMapping() var documentSnapshot = new Mock(MockBehavior.Strict); documentSnapshot.SetupGet(doc => doc.Uri).Returns(_mockDocumentUri); - var textSnapshot = new StringTextSnapshot(s_mockGeneratedContent, 1); + var textSnapshot = new StringTextSnapshot(MockGeneratedContent, 1); - var textSpanAsRange = _sourceTextGenerated.GetRange(textSpan); - var mappedRange = VsLspFactory.CreateSingleLineRange(2, character: 1, length: 10); + var textSpanAsRange = s_sourceTextGenerated.GetRange(textSpan); + var mappedRange = LspFactory.CreateSingleLineRange(2, character: 1, length: 10); var mappingResult = new RazorMapToDocumentRangesResponse() { @@ -63,7 +58,6 @@ public async Task MapSpans_WithinRange_ReturnsMapping() }; var requestInvoker = new TestLSPRequestInvoker([(LanguageServerConstants.RazorMapToDocumentRangesEndpoint, mappingResult)]); - var lazyDocumentManager = new Lazy(() => { var documentManager = new TestDocumentManager(); @@ -75,13 +69,13 @@ public async Task MapSpans_WithinRange_ReturnsMapping() var service = new RazorLSPSpanMappingService(documentMappingProvider, documentSnapshot.Object, textSnapshot); - var expectedSpan = _sourceTextRazor.GetTextSpan(mappedRange); - var expectedLinePosition = _sourceTextRazor.GetLinePositionSpan(expectedSpan); + var expectedSpan = s_sourceTextRazor.GetTextSpan(mappedRange); + var expectedLinePosition = s_sourceTextRazor.GetLinePositionSpan(expectedSpan); var expectedFilePath = _mockDocumentUri.LocalPath; var expectedResult = (expectedFilePath, expectedLinePosition, expectedSpan); // Act - var result = await service.MapSpansAsyncTest(spans, _sourceTextGenerated, _sourceTextRazor); + var result = await service.MapSpansAsyncTest(spans, s_sourceTextGenerated, s_sourceTextRazor); // Assert Assert.Single(result, expectedResult); @@ -97,9 +91,9 @@ public async Task MapSpans_OutsideRange_ReturnsEmpty() var documentSnapshot = new Mock(MockBehavior.Strict); documentSnapshot.SetupGet(doc => doc.Uri).Returns(_mockDocumentUri); - var textSnapshot = new StringTextSnapshot(s_mockGeneratedContent, 1); + var textSnapshot = new StringTextSnapshot(MockGeneratedContent, 1); - var textSpanAsRange = _sourceTextGenerated.GetRange(textSpan); + var textSpanAsRange = s_sourceTextGenerated.GetRange(textSpan); var requestInvoker = new StrictMock(); var lazyDocumentManager = new Lazy(() => new TestDocumentManager()); @@ -109,7 +103,7 @@ public async Task MapSpans_OutsideRange_ReturnsEmpty() var service = new RazorLSPSpanMappingService(documentMappingProvider, documentSnapshot.Object, textSnapshot); // Act - var result = await service.MapSpansAsyncTest(spans, _sourceTextGenerated, _sourceTextRazor); + var result = await service.MapSpansAsyncTest(spans, s_sourceTextGenerated, s_sourceTextRazor); // Assert Assert.Empty(result); @@ -120,7 +114,7 @@ public void MapSpans_GetMappedSpanResults_MappingErrorReturnsDefaultMappedSpan() { // Arrange var sourceTextRazor = SourceText.From(""); - var response = new RazorMapToDocumentRangesResponse { Ranges = new Range[] { VsLspFactory.UndefinedRange } }; + var response = new RazorMapToDocumentRangesResponse { Ranges = [LspFactory.UndefinedRange] }; // Act var results = RazorLSPSpanMappingService.GetMappedSpanResults(_mockDocumentUri.LocalPath, sourceTextRazor, response); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestDocumentManager.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestDocumentManager.cs index 9637feecd45..a18c30c2337 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestDocumentManager.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestDocumentManager.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Text; namespace Microsoft.VisualStudio.Razor.LanguageClient; @@ -73,7 +72,7 @@ private void UpdateCSharpServerDocument(IReadOnlyList changes, Virt var rangesAndTexts = changes.Select(c => { GetLinesAndOffsets(virtualSourceText, c.OldSpan, out var startLine, out var startCharacter, out var endLine, out var endCharacter); - var range = VsLspFactory.CreateRange(startLine, startCharacter, endLine, endCharacter); + var range = LspFactory.CreateRange(startLine, startCharacter, endLine, endCharacter); return (range, c.NewText); }).ToArray(); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestFormattingOptionsProvider.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestFormattingOptionsProvider.cs index 8d125063368..853c2a48a8d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestFormattingOptionsProvider.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestFormattingOptionsProvider.cs @@ -3,11 +3,11 @@ using System; using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using FormattingOptions = Microsoft.VisualStudio.LanguageServer.Protocol.FormattingOptions; namespace Microsoft.VisualStudio.Razor.LanguageClient; -internal class TestFormattingOptionsProvider : FormattingOptionsProvider +internal class TestFormattingOptionsProvider(FormattingOptions options) : FormattingOptionsProvider { public static readonly TestFormattingOptionsProvider Default = new( new FormattingOptions() @@ -15,12 +15,6 @@ internal class TestFormattingOptionsProvider : FormattingOptionsProvider InsertSpaces = true, TabSize = 4, }); - private readonly FormattingOptions _options; - public TestFormattingOptionsProvider(FormattingOptions options) - { - _options = options; - } - - public override FormattingOptions? GetOptions(Uri uri) => _options; + public override FormattingOptions? GetOptions(Uri uri) => options; } diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestRazorLSPSpanMappingService.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestRazorLSPSpanMappingService.cs index 3b46d91e9c7..71929d39ac0 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestRazorLSPSpanMappingService.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/TestRazorLSPSpanMappingService.cs @@ -11,7 +11,6 @@ using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Razor.Protocol; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Razor.LanguageClient.DocumentMapping; namespace Microsoft.VisualStudio.Razor.LanguageClient; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj index fd54e585914..6b21e7dd53b 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj @@ -32,6 +32,7 @@ + diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/RazorLanguageService_IVsLanguageDebugInfoTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/RazorLanguageService_IVsLanguageDebugInfoTest.cs index b4509b4df5f..47c5b81fd03 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/RazorLanguageService_IVsLanguageDebugInfoTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/RazorLanguageService_IVsLanguageDebugInfoTest.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.Editor; using Microsoft.VisualStudio.Editor; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Razor.Debugging; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.TextManager.Interop; @@ -69,7 +68,7 @@ public void ValidateBreakpointLocation_NullBreakpointRange_ReturnsEFail() public void ValidateBreakpointLocation_ValidBreakpointRange_ReturnsSOK() { // Arrange - var breakpointRange = VsLspFactory.CreateRange(2, 4, 3, 5); + var breakpointRange = LspFactory.CreateRange(2, 4, 3, 5); var breakpointResolver = Mock.Of(resolver => resolver.TryResolveBreakpointRangeAsync(It.IsAny(), 0, 0, It.IsAny()) == System.Threading.Tasks.Task.FromResult(breakpointRange), MockBehavior.Strict); var languageService = CreateLanguageServiceWith(breakpointResolver); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Telemetry/TelemetryReporterTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Telemetry/TelemetryReporterTests.cs index f16381fe46a..2e37fe2dc58 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Telemetry/TelemetryReporterTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Telemetry/TelemetryReporterTests.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.VisualStudio.Editor.Razor.Test.Shared; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Telemetry; using Microsoft.VisualStudio.Telemetry.Metrics; using StreamJsonRpc;