$$
+ """,
+ expected: """
+
+ """,
+ enableAutoClosingTags: false);
}
internal override IOnAutoInsertProvider CreateProvider()
- {
- var configService = StrictMock.Of();
- var optionsMonitor = new RazorLSPOptionsMonitor(configService, Options);
-
- var provider = new AutoClosingTagOnAutoInsertProvider(optionsMonitor);
- return provider;
- }
+ => new AutoClosingTagOnAutoInsertProvider();
}
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/CloseTextTagOnAutoInsertProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/CloseTextTagOnAutoInsertProviderTest.cs
index 18fed07bd85..74b17456c4c 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/CloseTextTagOnAutoInsertProviderTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/CloseTextTagOnAutoInsertProviderTest.cs
@@ -1,8 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
-using Microsoft.AspNetCore.Razor.Test.Common;
+using Microsoft.CodeAnalysis.Razor.AutoInsert;
using Xunit;
using Xunit.Abstractions;
@@ -14,36 +13,30 @@ public class CloseTextTagOnAutoInsertProviderTest(ITestOutputHelper testOutput)
public void OnTypeCloseAngle_ClosesTextTag()
{
RunAutoInsertTest(
-input: @"
-@{
- $$
-}
-",
-expected: @"
-@{
- $0
-}
-");
+ input: """
+ @{
+ $$
+ }
+ """,
+ expected: """
+ @{
+ $0
+ }
+ """);
}
[Fact]
public void OnTypeCloseAngle_OutsideRazorBlock_DoesNotCloseTextTag()
{
RunAutoInsertTest(
-input: @"
- $$
-",
-expected: @"
-
-");
+ input: """
+ $$
+ """,
+ expected: """
+
+ """);
}
- internal override IOnAutoInsertProvider CreateProvider()
- {
- var configService = StrictMock.Of();
- var optionsMonitor = new RazorLSPOptionsMonitor(configService, RazorLSPOptions.Default);
-
- var provider = new CloseTextTagOnAutoInsertProvider(optionsMonitor);
- return provider;
- }
+ internal override IOnAutoInsertProvider CreateProvider() =>
+ new CloseTextTagOnAutoInsertProvider();
}
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.NetFx.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.NetFx.cs
index 26b5acd8561..b5bb61530e2 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.NetFx.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.NetFx.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Formatting;
using Microsoft.AspNetCore.Razor.LanguageServer.Test;
+using Microsoft.CodeAnalysis.Razor.AutoInsert;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
@@ -27,7 +28,15 @@ public async Task Handle_SingleProvider_InvokesProvider()
var optionsMonitor = GetOptionsMonitor();
var insertProvider = new TestOnAutoInsertProvider(">", canResolve: true);
var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, formattingService, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ formattingService,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -69,7 +78,15 @@ public async Task Handle_MultipleProviderSameTrigger_UsesSuccessful()
ResolvedTextEdit = VsLspFactory.CreateTextEdit(position: (0, 0), string.Empty)
};
var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider1, insertProvider2], optionsMonitor, TestAdhocWorkspaceFactory.Instance, formattingService, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider1, insertProvider2]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ formattingService,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -114,7 +131,15 @@ public async Task Handle_MultipleProviderSameTrigger_UsesFirstSuccessful()
ResolvedTextEdit = VsLspFactory.CreateTextEdit(position: (0, 0), string.Empty)
};
var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider1, insertProvider2], optionsMonitor, TestAdhocWorkspaceFactory.Instance, formattingService, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider1, insertProvider2]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ formattingService,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -151,7 +176,15 @@ public async Task Handle_NoApplicableProvider_CallsProviderAndReturnsNull()
var optionsMonitor = GetOptionsMonitor();
var insertProvider = new TestOnAutoInsertProvider(">", canResolve: false);
var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, formattingService, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ formattingService,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -186,7 +219,15 @@ public async Task Handle_OnTypeFormattingOff_Html_CallsLanguageServer()
var optionsMonitor = GetOptionsMonitor(formatOnType: false);
var insertProvider = new TestOnAutoInsertProvider("<", canResolve: false);
var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, formattingService, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ formattingService,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -219,7 +260,15 @@ public async Task Handle_AutoInsertAttributeQuotesOff_Html_DoesNotCallLanguageSe
var optionsMonitor = GetOptionsMonitor(autoInsertAttributeQuotes: false);
var insertProvider = new TestOnAutoInsertProvider("<", canResolve: false);
var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, formattingService, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ formattingService,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -357,7 +406,15 @@ private async Task VerifyCSharpOnAutoInsertAsync(string input, string expected,
var optionsMonitor = GetOptionsMonitor();
var insertProvider = new TestOnAutoInsertProvider("!!!", canResolve: false);
var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, formattingService, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ formattingService,
+ LoggerFactory);
var text = codeDocument.Source.Text;
var @params = new VSInternalDocumentOnAutoInsertParams()
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.cs
index d5c57f9abff..6811b702468 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/OnAutoInsertEndpointTest.cs
@@ -6,7 +6,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.LanguageServer.Test;
-using Microsoft.CodeAnalysis.Razor.Formatting;
+using Microsoft.CodeAnalysis.Razor.AutoInsert;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Xunit;
using Xunit.Abstractions;
@@ -27,7 +27,16 @@ public async Task Handle_MultipleProviderUnmatchingTrigger_ReturnsNull()
var optionsMonitor = GetOptionsMonitor();
var insertProvider1 = new TestOnAutoInsertProvider(">", canResolve: true);
var insertProvider2 = new TestOnAutoInsertProvider("<", canResolve: true);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider1, insertProvider2], optionsMonitor, TestAdhocWorkspaceFactory.Instance, null!, LoggerFactory);
+ var autoInsertService = new AutoInsertService([insertProvider1, insertProvider2]);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ autoInsertService,
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ null!,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -61,7 +70,15 @@ public async Task Handle_DocumentNotFound_ReturnsNull()
var optionsMonitor = GetOptionsMonitor();
var insertProvider = new TestOnAutoInsertProvider(">", canResolve: true);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, null!, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ null!,
+ LoggerFactory);
var uri = new Uri("file://path/test.razor");
var @params = new VSInternalDocumentOnAutoInsertParams()
{
@@ -97,7 +114,15 @@ public async Task Handle_UnsupportedCodeDocument_ReturnsNull()
var documentContext = CreateDocumentContext(uri, codeDocument);
var optionsMonitor = GetOptionsMonitor();
var insertProvider = new TestOnAutoInsertProvider(">", canResolve: true);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, null!, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor,
+ TestAdhocWorkspaceFactory.Instance,
+ razorFormattingService: null!,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -131,7 +156,14 @@ public async Task Handle_OnTypeFormattingOff_CSharp_ReturnsNull()
var documentContext = CreateDocumentContext(uri, codeDocument);
var optionsMonitor = GetOptionsMonitor(formatOnType: false);
var insertProvider = new TestOnAutoInsertProvider(">", canResolve: false);
- var endpoint = new OnAutoInsertEndpoint(LanguageServerFeatureOptions, DocumentMappingService, languageServer, [insertProvider], optionsMonitor, TestAdhocWorkspaceFactory.Instance, null!, LoggerFactory);
+ var endpoint = new OnAutoInsertEndpoint(
+ LanguageServerFeatureOptions,
+ DocumentMappingService,
+ languageServer,
+ new AutoInsertService([insertProvider]),
+ optionsMonitor, TestAdhocWorkspaceFactory.Instance,
+ razorFormattingService: null!,
+ LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
{
TextDocument = new TextDocumentIdentifier { Uri = uri, },
@@ -161,12 +193,15 @@ private class TestOnAutoInsertProvider(string triggerCharacter, bool canResolve)
public string TriggerCharacter { get; } = triggerCharacter;
- // Disabling because [NotNullWhen] is available in two Assemblies and causes warnings
- public bool TryResolveInsertion(Position position, FormattingContext context, [NotNullWhen(true)] out TextEdit? edit, out InsertTextFormat format)
+ public bool TryResolveInsertion(
+ Position position,
+ RazorCodeDocument codeDocument,
+ bool enableAutoClosingTags,
+ [NotNullWhen(true)] out VSInternalDocumentOnAutoInsertResponseItem? autoInsertEdit)
{
Called = true;
- edit = ResolvedTextEdit!;
- format = default;
+ autoInsertEdit = canResolve ? new() { TextEdit = ResolvedTextEdit!, TextEditFormat = InsertTextFormat.Plaintext } : null;
+
return canResolve;
}
}
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs
index 2d77fa619a3..c5e809d705a 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/AutoInsert/RazorOnAutoInsertProviderTestBase.cs
@@ -6,14 +6,11 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.LanguageServer.Test;
using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer;
-using Microsoft.CodeAnalysis.Razor.Formatting;
-using Microsoft.CodeAnalysis.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.AutoInsert;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Moq;
using Xunit;
using Xunit.Abstractions;
@@ -28,7 +25,7 @@ protected RazorOnAutoInsertProviderTestBase(ITestOutputHelper testOutput)
internal abstract IOnAutoInsertProvider CreateProvider();
- protected void RunAutoInsertTest(string input, string expected, int tabSize = 4, bool insertSpaces = true, string fileKind = default, IReadOnlyList tagHelpers = default)
+ protected void RunAutoInsertTest(string input, string expected, int tabSize = 4, bool insertSpaces = true, bool enableAutoClosingTags = true, string fileKind = default, IReadOnlyList tagHelpers = default)
{
// Arrange
TestFileMarkupParser.GetPosition(input, out input, out var location);
@@ -39,23 +36,14 @@ protected void RunAutoInsertTest(string input, string expected, int tabSize = 4,
var path = "file:///path/to/document.razor";
var uri = new Uri(path);
var codeDocument = CreateCodeDocument(source, uri.AbsolutePath, tagHelpers, fileKind: fileKind);
- var options = new FormattingOptions()
- {
- TabSize = tabSize,
- InsertSpaces = insertSpaces,
- };
var provider = CreateProvider();
- using var context = FormattingContext.Create(uri, Mock.Of(MockBehavior.Strict), codeDocument, options, TestAdhocWorkspaceFactory.Instance);
// Act
- if (!provider.TryResolveInsertion(position, context, out var edit, out _))
- {
- edit = null;
- }
+ provider.TryResolveInsertion(position, codeDocument, enableAutoClosingTags: enableAutoClosingTags, out var edit);
// Assert
- var edited = edit is null ? source : ApplyEdit(source, edit);
+ var edited = edit is null ? source : ApplyEdit(source, edit.TextEdit);
var actual = edited.ToString();
Assert.Equal(expected, actual);
}
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs
index bd93514e88f..2f668586916 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/DefaultCSharpCodeActionProviderTest.cs
@@ -333,7 +333,7 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(
codeDocument.SetCSharpDocument(csharpDocumentWithDiagnostic);
var documentSnapshot = Mock.Of(document =>
- document.GetGeneratedOutputAsync() == Task.FromResult(codeDocument) &&
+ document.GetGeneratedOutputAsync(It.IsAny()) == Task.FromResult(codeDocument) &&
document.GetTextAsync() == Task.FromResult(codeDocument.Source.Text) &&
document.Project.GetTagHelpersAsync(It.IsAny()) == new ValueTask>(tagHelpers), MockBehavior.Strict);
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs
index 610e0462269..86d1b8239e5 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CSharp/TypeAccessibilityCodeActionProviderTest.cs
@@ -464,7 +464,7 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(
codeDocument.SetCSharpDocument(csharpDocumentWithDiagnostic);
var documentSnapshot = Mock.Of(document =>
- document.GetGeneratedOutputAsync() == Task.FromResult(codeDocument) &&
+ document.GetGeneratedOutputAsync(It.IsAny()) == Task.FromResult(codeDocument) &&
document.GetTextAsync() == Task.FromResult(codeDocument.Source.Text) &&
document.Project.GetTagHelpersAsync(It.IsAny()) == new ValueTask>(tagHelpers), MockBehavior.Strict);
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs
index 297848bba6c..8bcc81013b1 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Html/DefaultHtmlCodeActionProviderTest.cs
@@ -152,7 +152,7 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(
var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, FileKinds.Component, importSources: default, tagHelpers);
var documentSnapshot = Mock.Of(document =>
- document.GetGeneratedOutputAsync() == Task.FromResult(codeDocument) &&
+ document.GetGeneratedOutputAsync(It.IsAny()) == Task.FromResult(codeDocument) &&
document.GetTextAsync() == Task.FromResult(codeDocument.Source.Text) &&
document.Project.GetTagHelpersAsync(It.IsAny()) == new ValueTask>(tagHelpers), MockBehavior.Strict);
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs
index 56874c402da..2a0e033c4b5 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ComponentAccessibilityCodeActionProviderTest.cs
@@ -464,7 +464,7 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(VSCodeActionP
codeDocument.SetCSharpDocument(csharpDocumentWithDiagnostic);
var documentSnapshot = Mock.Of(document =>
- document.GetGeneratedOutputAsync() == Task.FromResult(codeDocument) &&
+ document.GetGeneratedOutputAsync(It.IsAny()) == Task.FromResult(codeDocument) &&
document.GetTextAsync() == Task.FromResult(codeDocument.Source.Text) &&
document.Project.GetTagHelpersAsync(It.IsAny()) == new ValueTask>(tagHelpers), MockBehavior.Strict);
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ExtractToCodeBehindCodeActionProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ExtractToCodeBehindCodeActionProviderTest.cs
index a0995f885a9..698d462b310 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ExtractToCodeBehindCodeActionProviderTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ExtractToCodeBehindCodeActionProviderTest.cs
@@ -396,7 +396,7 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(VSCodeActionP
codeDocument.SetSyntaxTree(syntaxTree);
var documentSnapshot = Mock.Of(document =>
- document.GetGeneratedOutputAsync() == Task.FromResult(codeDocument) &&
+ document.GetGeneratedOutputAsync(It.IsAny()) == Task.FromResult(codeDocument) &&
document.GetTextAsync() == Task.FromResult(codeDocument.Source.Text), MockBehavior.Strict);
var sourceText = SourceText.From(text);
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DocumentPresentation/TextDocumentUriPresentationEndpointTests.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DocumentPresentation/TextDocumentUriPresentationEndpointTests.cs
index 52ee2ceb54a..3b814f35d33 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DocumentPresentation/TextDocumentUriPresentationEndpointTests.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DocumentPresentation/TextDocumentUriPresentationEndpointTests.cs
@@ -216,7 +216,7 @@ public async Task Handle_NoTypeNameIdentifier_ReturnsNull()
var builder = TagHelperDescriptorBuilder.Create("MyTagHelper", "MyAssembly");
var tagHelperDescriptor = builder.Build();
- var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync() == Task.FromResult(componentCodeDocument), MockBehavior.Strict);
+ var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync(It.IsAny()) == Task.FromResult(componentCodeDocument), MockBehavior.Strict);
var uri = new Uri("file://path/test.razor");
var documentContextFactory = CreateDocumentContextFactory(uri, codeDocument);
@@ -262,7 +262,7 @@ public async Task Handle_MultipleUris_ReturnsNull()
var documentMappingService = Mock.Of(
s => s.GetLanguageKind(codeDocument, It.IsAny(), It.IsAny()) == RazorLanguageKind.Html, MockBehavior.Strict);
- var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync() == Task.FromResult(codeDocument), MockBehavior.Strict);
+ var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync(false) == Task.FromResult(codeDocument), MockBehavior.Strict);
var uri = new Uri("file://path/test.razor");
var documentContextFactory = CreateDocumentContextFactory(uri, codeDocument);
@@ -313,7 +313,7 @@ public async Task Handle_NotComponent_ReturnsNull()
var documentMappingService = Mock.Of(
s => s.GetLanguageKind(codeDocument, It.IsAny(), It.IsAny()) == RazorLanguageKind.Html, MockBehavior.Strict);
- var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync() == Task.FromResult(codeDocument), MockBehavior.Strict);
+ var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync(false) == Task.FromResult(codeDocument), MockBehavior.Strict);
var droppedUri = new Uri("file:///c:/path/MyTagHelper.cshtml");
var uri = new Uri("file://path/test.razor");
@@ -422,7 +422,7 @@ public async Task Handle_CSharp_ReturnsNull()
s => s.GetLanguageKind(codeDocument, It.IsAny(), It.IsAny()) == RazorLanguageKind.CSharp &&
s.TryMapToGeneratedDocumentRange(csharpDocument, It.IsAny(), out projectedRange) == true, MockBehavior.Strict);
- var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync() == Task.FromResult(codeDocument), MockBehavior.Strict);
+ var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync(false) == Task.FromResult(codeDocument), MockBehavior.Strict);
var documentContextFactory = CreateDocumentContextFactory(uri, codeDocument);
var response = (WorkspaceEdit?)null;
@@ -466,7 +466,7 @@ public async Task Handle_DocumentNotFound_ReturnsNull()
var documentMappingService = Mock.Of(
s => s.GetLanguageKind(codeDocument, It.IsAny(), It.IsAny()) == RazorLanguageKind.Html, MockBehavior.Strict);
- var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync() == Task.FromResult(codeDocument), MockBehavior.Strict);
+ var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync(false) == Task.FromResult(codeDocument), MockBehavior.Strict);
var documentContextFactory = CreateDocumentContextFactory(uri, codeDocument);
var response = (WorkspaceEdit?)null;
@@ -511,7 +511,7 @@ public async Task Handle_UnsupportedCodeDocument_ReturnsNull()
var documentMappingService = Mock.Of(
s => s.GetLanguageKind(codeDocument, It.IsAny(), It.IsAny()) == RazorLanguageKind.Html, MockBehavior.Strict);
- var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync() == Task.FromResult(codeDocument), MockBehavior.Strict);
+ var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync(false) == Task.FromResult(codeDocument), MockBehavior.Strict);
var documentContextFactory = CreateDocumentContextFactory(uri, codeDocument);
var response = new WorkspaceEdit();
@@ -555,7 +555,7 @@ public async Task Handle_NoUris_ReturnsNull()
var documentMappingService = Mock.Of(
s => s.GetLanguageKind(codeDocument, It.IsAny(), It.IsAny()) == RazorLanguageKind.Html, MockBehavior.Strict);
- var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync() == Task.FromResult(codeDocument), MockBehavior.Strict);
+ var documentSnapshot = Mock.Of(s => s.GetGeneratedOutputAsync(false) == Task.FromResult(codeDocument), MockBehavior.Strict);
var documentContextFactory = CreateDocumentContextFactory(uri, codeDocument);
var response = (WorkspaceEdit?)null;
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs
index ba5973a36ef..f35c3dffeeb 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingContentValidationPassTest.cs
@@ -132,7 +132,13 @@ private static FormattingContext CreateFormattingContext(SourceText source, int
InsertSpaces = insertSpaces,
};
- var context = FormattingContext.Create(uri, documentSnapshot, codeDocument, options, TestAdhocWorkspaceFactory.Instance);
+ var context = FormattingContext.Create(
+ uri,
+ documentSnapshot,
+ codeDocument,
+ options,
+ new LspFormattingCodeDocumentProvider(),
+ TestAdhocWorkspaceFactory.Instance);
return context;
}
@@ -146,7 +152,7 @@ private static (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnaps
var documentSnapshot = new Mock(MockBehavior.Strict);
documentSnapshot
- .Setup(d => d.GetGeneratedOutputAsync())
+ .Setup(d => d.GetGeneratedOutputAsync(It.IsAny()))
.ReturnsAsync(codeDocument);
documentSnapshot
.Setup(d => d.TargetPath)
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs
index 60adc04a1fc..7ca4655ac5e 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingDiagnosticValidationPassTest.cs
@@ -129,7 +129,13 @@ private static FormattingContext CreateFormattingContext(SourceText source, int
InsertSpaces = insertSpaces,
};
- var context = FormattingContext.Create(uri, documentSnapshot, codeDocument, options, TestAdhocWorkspaceFactory.Instance);
+ var context = FormattingContext.Create(
+ uri,
+ documentSnapshot,
+ codeDocument,
+ options,
+ new LspFormattingCodeDocumentProvider(),
+ TestAdhocWorkspaceFactory.Instance);
return context;
}
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingTestBase.cs
index 62221cac30b..dc8c6ddd2be 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingTestBase.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/FormattingTestBase.cs
@@ -287,7 +287,7 @@ internal static IDocumentSnapshot CreateDocumentSnapshot(string path, ImmutableA
{
var documentSnapshot = new Mock(MockBehavior.Strict);
documentSnapshot
- .Setup(d => d.GetGeneratedOutputAsync())
+ .Setup(d => d.GetGeneratedOutputAsync(It.IsAny()))
.ReturnsAsync(codeDocument);
documentSnapshot
.Setup(d => d.FilePath)
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/TestRazorFormattingService.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/TestRazorFormattingService.cs
index 151cfc51df9..21b381771c8 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/TestRazorFormattingService.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/TestRazorFormattingService.cs
@@ -57,6 +57,9 @@ public static async Task CreateWithFullSupportAsync(
new FormattingContentValidationPass(mappingService, loggerFactory),
};
- return new RazorFormattingService(passes, TestAdhocWorkspaceFactory.Instance);
+ return new RazorFormattingService(
+ passes,
+ new LspFormattingCodeDocumentProvider(),
+ TestAdhocWorkspaceFactory.Instance);
}
}
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Hover/HoverServiceTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Hover/HoverServiceTest.cs
index 411d6405171..4430868d72e 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Hover/HoverServiceTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Hover/HoverServiceTest.cs
@@ -923,7 +923,7 @@ public void Increment(){
var sourceText = SourceText.From(txt);
var snapshot = Mock.Of(d =>
- d.GetGeneratedOutputAsync() == Task.FromResult(codeDocument) &&
+ d.GetGeneratedOutputAsync(It.IsAny()) == Task.FromResult(codeDocument) &&
d.FilePath == path &&
d.FileKind == FileKinds.Component &&
d.GetTextAsync() == Task.FromResult(sourceText) &&
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 748262ec53a..455da63ae60 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
@@ -937,7 +937,7 @@ private static DocumentContext CreateDocumentContext(
.SetupGet(x => x.Project)
.Returns(projectSnapshot.Object);
documentSnapshotMock
- .Setup(x => x.GetGeneratedOutputAsync())
+ .Setup(x => x.GetGeneratedOutputAsync(It.IsAny()))
.ReturnsAsync(document);
documentSnapshotMock
.Setup(x => x.GetTextAsync())
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestDocumentSnapshot.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestDocumentSnapshot.cs
index 65c0670b26c..645bec36bae 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestDocumentSnapshot.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestDocumentSnapshot.cs
@@ -79,7 +79,7 @@ public TestDocumentSnapshot(ProjectSnapshot projectSnapshot, DocumentState docum
public HostDocument HostDocument => State.HostDocument;
- public override Task GetGeneratedOutputAsync()
+ public override Task GetGeneratedOutputAsync(bool _)
{
if (_codeDocument is null)
{
diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RazorComponentDefinitionServiceTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RazorComponentDefinitionServiceTest.cs
index 22c43a1a755..041b95c6eee 100644
--- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RazorComponentDefinitionServiceTest.cs
+++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/RazorComponentDefinitionServiceTest.cs
@@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.GoToDefinition;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;