From a52d8ad70d1c7a969f6896cf7e59c3f9f6a6c286 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 5 Mar 2025 13:28:29 +1100 Subject: [PATCH 01/14] Remove unused or invalid options in OOP --- .../Remote/RemoteClientInitializationOptions.cs | 8 +------- .../Initialization/RemoteLanguageServerFeatureOptions.cs | 4 ++-- .../Remote/RemoteServiceInvoker.cs | 2 -- .../Cohost/CohostEndpointTestBase.cs | 2 -- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs index c836720ad15..aeeddb2fa7f 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs @@ -16,15 +16,9 @@ internal struct RemoteClientInitializationOptions [JsonPropertyName("htmlVirtualDocumentSuffix")] public required string HtmlVirtualDocumentSuffix { get; set; } - [JsonPropertyName("includeProjectKeyInGeneratedFilePath")] - public required bool IncludeProjectKeyInGeneratedFilePath { get; set; } - [JsonPropertyName("returnCodeActionAndRenamePathsWithPrefixedSlash")] public required bool ReturnCodeActionAndRenamePathsWithPrefixedSlash { get; set; } - [JsonPropertyName("forceRuntimeCodeGeneration")] - public required bool ForceRuntimeCodeGeneration { get; set; } - [JsonPropertyName("supportsFileManipulation")] public required bool SupportsFileManipulation { get; set; } @@ -38,5 +32,5 @@ internal struct RemoteClientInitializationOptions public required bool SupportsSoftSelectionInCompletion { get; set; } [JsonPropertyName("useVSCodeCompletionTriggerCharacters")] - public bool UseVsCodeCompletionTriggerCharacters { get; set; } + public required bool UseVsCodeCompletionTriggerCharacters { get; set; } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs index 3a3965003cc..cb9f607c752 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs @@ -42,11 +42,11 @@ public void SetOptions(RemoteClientInitializationOptions options) public override bool ReturnCodeActionAndRenamePathsWithPrefixedSlash => _options.ReturnCodeActionAndRenamePathsWithPrefixedSlash; - public override bool IncludeProjectKeyInGeneratedFilePath => _options.IncludeProjectKeyInGeneratedFilePath; + public override bool IncludeProjectKeyInGeneratedFilePath => throw new InvalidOperationException("This option does not apply in cohosting."); public override bool UseRazorCohostServer => _options.UseRazorCohostServer; - public override bool ForceRuntimeCodeGeneration => _options.ForceRuntimeCodeGeneration; + public override bool ForceRuntimeCodeGeneration => true; public override bool UseNewFormattingEngine => _options.UseNewFormattingEngine; diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs index 693e4bc2f96..29788117544 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs @@ -170,9 +170,7 @@ Task InitializeOOPAsync(RazorRemoteHostClient remoteClient) UseRazorCohostServer = _languageServerFeatureOptions.UseRazorCohostServer, UsePreciseSemanticTokenRanges = _languageServerFeatureOptions.UsePreciseSemanticTokenRanges, HtmlVirtualDocumentSuffix = _languageServerFeatureOptions.HtmlVirtualDocumentSuffix, - IncludeProjectKeyInGeneratedFilePath = _languageServerFeatureOptions.IncludeProjectKeyInGeneratedFilePath, ReturnCodeActionAndRenamePathsWithPrefixedSlash = _languageServerFeatureOptions.ReturnCodeActionAndRenamePathsWithPrefixedSlash, - ForceRuntimeCodeGeneration = _languageServerFeatureOptions.ForceRuntimeCodeGeneration, SupportsFileManipulation = _languageServerFeatureOptions.SupportsFileManipulation, ShowAllCSharpCodeActions = _languageServerFeatureOptions.ShowAllCSharpCodeActions, UseNewFormattingEngine = _languageServerFeatureOptions.UseNewFormattingEngine, 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..52ae085cf5c 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 @@ -76,11 +76,9 @@ protected override async Task InitializeAsync() _clientInitializationOptions = new() { HtmlVirtualDocumentSuffix = ".g.html", - IncludeProjectKeyInGeneratedFilePath = false, UsePreciseSemanticTokenRanges = false, UseRazorCohostServer = true, ReturnCodeActionAndRenamePathsWithPrefixedSlash = false, - ForceRuntimeCodeGeneration = false, SupportsFileManipulation = true, ShowAllCSharpCodeActions = false, UseNewFormattingEngine = false, From f5e75017f47beaceb568c00be06c961624c15d9c Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 5 Mar 2025 13:44:52 +1100 Subject: [PATCH 02/14] Remove FuseFast usage for cohosting tests, because they'll all fuse! --- .../Cohost/CodeActions/AddUsingTests.cs | 14 +++--- .../CodeActions/CSharpCodeActionTests.cs | 32 ++++++------ .../CohostCodeActionsEndpointTestBase.cs | 6 +-- .../CreateComponentFromTagTests.cs | 8 +-- .../CodeActions/ExtractToCodeBehindTests.cs | 6 +-- .../CodeActions/ExtractToComponentTests.cs | 6 +-- .../CodeActions/GenerateEventHandlerTests.cs | 26 +++++----- .../CodeActions/PromoteUsingDirectiveTests.cs | 16 +++--- .../CodeActions/TypeAccessibilityTests.cs | 12 ++--- .../Cohost/CodeActions/WrapAttributeTests.cs | 14 +++--- .../CohostDocumentCompletionEndpointTest.cs | 50 +++++++++---------- .../CohostDocumentHighlightEndpointTest.cs | 19 +++---- .../CohostDocumentPullDiagnosticsTest.cs | 16 +++--- .../CohostDocumentSpellCheckEndpointTest.cs | 6 +-- .../CohostDocumentSymbolEndpointTest.cs | 8 ++- .../CohostFindAllReferencesEndpointTest.cs | 10 ++-- .../Cohost/CohostFoldingRangeEndpointTest.cs | 29 +++++------ .../CohostGoToDefinitionEndpointTest.cs | 22 ++++---- .../CohostGoToImplementationEndpointTest.cs | 14 ++---- .../Cohost/CohostHoverEndpointTest.cs | 16 +++--- .../Cohost/CohostInlayHintEndpointTest.cs | 15 ++---- .../CohostInlineCompletionEndpointTest.cs | 10 ++-- .../CohostLinkedEditingRangeEndpointTest.cs | 21 ++++---- .../Cohost/CohostOnAutoInsertEndpointTest.cs | 20 ++++---- .../CohostOnTypeFormattingEndpointTest.cs | 14 +++--- .../CohostRangeFormattingEndpointTest.cs | 8 ++- .../Cohost/CohostRenameEndpointTest.cs | 13 ++--- .../CohostSemanticTokensRangeEndpointTest.cs | 11 ++-- .../Cohost/CohostSignatureHelpEndpointTest.cs | 12 ++--- .../CohostTextPresentationEndpointTest.cs | 7 +-- .../CohostUriPresentationEndpointTest.cs | 22 ++++---- ...ohostValidateBreakableRangeEndpointTest.cs | 16 +++--- 32 files changed, 218 insertions(+), 281 deletions(-) diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/AddUsingTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/AddUsingTests.cs index 9251f5ab424..a932a074894 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/AddUsingTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/AddUsingTests.cs @@ -2,15 +2,15 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Xunit; using Xunit.Abstractions; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class AddUsingTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class AddUsingTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task FullyQualify() { var input = """ @@ -30,7 +30,7 @@ public async Task FullyQualify() await VerifyCodeActionAsync(input, expected, "System.Text.StringBuilder"); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task FullyQualify_Multiple() { await VerifyCodeActionAsync( @@ -58,7 +58,7 @@ public class StringBuilder childActionIndex: 0); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task AddUsing() { var input = """ @@ -79,7 +79,7 @@ @using System.Text await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeFixProviderNames.AddImport); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task AddUsing_Typo() { var input = """ @@ -100,7 +100,7 @@ @using System.Text await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeFixProviderNames.AddImport); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task AddUsing_WithExisting() { var input = """ diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CSharpCodeActionTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CSharpCodeActionTests.cs index af52bdac27b..bc9deed5dfe 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CSharpCodeActionTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CSharpCodeActionTests.cs @@ -2,15 +2,15 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.ExternalAccess.Razor; +using Xunit; using Xunit.Abstractions; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class CSharpCodeActionTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class CSharpCodeActionTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task GenerateConstructor() { var input = """ @@ -45,7 +45,7 @@ public Goo() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.GenerateConstructorFromMembers); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task UseExpressionBodiedMember() { var input = """ @@ -78,7 +78,7 @@ @using System.Linq await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.UseExpressionBody); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task IntroduceLocal() { var input = """ @@ -125,7 +125,7 @@ void M(string[] args) await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.IntroduceVariable); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task IntroduceLocal_All() { var input = """ @@ -172,7 +172,7 @@ void M(string[] args) await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.IntroduceVariable, childActionIndex: 1); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertConcatenationToInterpolatedString_CSharpStatement() { var input = """ @@ -190,7 +190,7 @@ public async Task ConvertConcatenationToInterpolatedString_CSharpStatement() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertConcatenationToInterpolatedString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertConcatenationToInterpolatedString_ExplicitExpression() { var input = """ @@ -204,7 +204,7 @@ public async Task ConvertConcatenationToInterpolatedString_ExplicitExpression() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertConcatenationToInterpolatedString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertConcatenationToInterpolatedString_CodeBlock() { var input = """ @@ -224,7 +224,7 @@ public async Task ConvertConcatenationToInterpolatedString_CodeBlock() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertConcatenationToInterpolatedString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertBetweenRegularAndVerbatimInterpolatedString_CodeBlock() { var input = """ @@ -244,7 +244,7 @@ public async Task ConvertBetweenRegularAndVerbatimInterpolatedString_CodeBlock() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertBetweenRegularAndVerbatimInterpolatedString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertBetweenRegularAndVerbatimInterpolatedString_CodeBlock2() { var input = """ @@ -264,7 +264,7 @@ public async Task ConvertBetweenRegularAndVerbatimInterpolatedString_CodeBlock2( await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertBetweenRegularAndVerbatimInterpolatedString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertBetweenRegularAndVerbatimString_CodeBlock() { var input = """ @@ -284,7 +284,7 @@ public async Task ConvertBetweenRegularAndVerbatimString_CodeBlock() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertBetweenRegularAndVerbatimString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertBetweenRegularAndVerbatimString_CodeBlock2() { var input = """ @@ -304,7 +304,7 @@ public async Task ConvertBetweenRegularAndVerbatimString_CodeBlock2() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertBetweenRegularAndVerbatimString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertPlaceholderToInterpolatedString_CodeBlock() { var input = """ @@ -324,7 +324,7 @@ public async Task ConvertPlaceholderToInterpolatedString_CodeBlock() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertPlaceholderToInterpolatedString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task ConvertToInterpolatedString_CodeBlock() { var input = """ @@ -344,7 +344,7 @@ public async Task ConvertToInterpolatedString_CodeBlock() await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.ConvertToInterpolatedString); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task AddDebuggerDisplay() { var input = """ 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..ae823ac9bca 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 @@ -28,14 +28,10 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public abstract class CohostCodeActionsEndpointTestBase(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public abstract class CohostCodeActionsEndpointTestBase(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - protected bool ForceRuntimeCodeGeneration => context.ForceRuntimeCodeGeneration; - private protected async Task VerifyCodeActionAsync(TestCode input, string? expected, string codeActionName, int childActionIndex = 0, string? fileKind = null, (string filePath, string contents)[]? additionalFiles = null, (Uri fileUri, string contents)[]? additionalExpectedFiles = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var fileSystem = (RemoteFileSystem)OOPExportProvider.GetExportedValue(); fileSystem.GetTestAccessor().SetFileSystem(new TestFileSystem(additionalFiles)); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CreateComponentFromTagTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CreateComponentFromTagTests.cs index 5be6dd13a2e..d6c91c7dc14 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CreateComponentFromTagTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/CreateComponentFromTagTests.cs @@ -2,15 +2,15 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; +using Xunit; using Xunit.Abstractions; using WorkspacesSR = Microsoft.CodeAnalysis.Razor.Workspaces.Resources.SR; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class CreateComponentFromTagTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class CreateComponentFromTagTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task CreateComponentFromTag() { await VerifyCodeActionAsync( @@ -29,7 +29,7 @@ await VerifyCodeActionAsync( (FileUri("Hello.razor"), "")]); } - [FuseFact] + [Fact] public async Task Attribute() { await VerifyCodeActionAsync( diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToCodeBehindTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToCodeBehindTests.cs index b5a479aff17..68c7d829236 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToCodeBehindTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToCodeBehindTests.cs @@ -2,15 +2,15 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; +using Xunit; using Xunit.Abstractions; using WorkspacesSR = Microsoft.CodeAnalysis.Razor.Workspaces.Resources.SR; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class ExtractToCodeBehindTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class ExtractToCodeBehindTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task ExtractToCodeBehind() { await VerifyCodeActionAsync( diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToComponentTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToComponentTests.cs index 8382f69ca59..fd7357a946f 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToComponentTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/ExtractToComponentTests.cs @@ -2,15 +2,15 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; +using Xunit; using Xunit.Abstractions; using WorkspacesSR = Microsoft.CodeAnalysis.Razor.Workspaces.Resources.SR; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class ExtractToComponentTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class ExtractToComponentTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task ExtractToComponent() { await VerifyCodeActionAsync( diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/GenerateEventHandlerTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/GenerateEventHandlerTests.cs index 5b2840d1e31..3086da48134 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/GenerateEventHandlerTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/GenerateEventHandlerTests.cs @@ -2,15 +2,15 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; +using Xunit; using Xunit.Abstractions; using WorkspacesSR = Microsoft.CodeAnalysis.Razor.Workspaces.Resources.SR; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class GenerateEventHandlerTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class GenerateEventHandlerTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task NoCodeBlock() { var input = """ @@ -30,7 +30,7 @@ private void DoesNotExist(MouseEventArgs args) await VerifyCodeActionAsync(input, expected, WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task CodeBlock() { var input = """ @@ -56,7 +56,7 @@ private void DoesNotExist(MouseEventArgs args) await VerifyCodeActionAsync(input, expected, WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task BindSet() { var input = """ @@ -84,7 +84,7 @@ private void DoesNotExist(string args) await VerifyCodeActionAsync(input, expected, WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task BindAfter() { var input = """ @@ -112,7 +112,7 @@ private void DoesNotExist() await VerifyCodeActionAsync(input, expected, WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task Callback() { var input = """ @@ -138,7 +138,7 @@ private void DoesNotExist(InputFileChangeEventArgs args) await VerifyCodeActionAsync(input, expected, WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task AsyncCallback() { var input = """ @@ -164,7 +164,7 @@ private Task DoesNotExistAsync(string args) await VerifyCodeActionAsync(input, expected, WorkspacesSR.FormatGenerate_Async_Event_Handler_Title("DoesNotExistAsync")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task BadCodeBehind() { await VerifyCodeActionAsync( @@ -192,7 +192,7 @@ public partial class NotAComponent codeActionName: WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task CodeBehind() { await VerifyCodeActionAsync( @@ -231,7 +231,7 @@ private void DoesNotExist(Microsoft.AspNetCore.Components.Web.MouseEventArgs arg codeActionName: WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task EmptyCodeBehind() { await VerifyCodeActionAsync( @@ -264,7 +264,7 @@ private void DoesNotExist(Microsoft.AspNetCore.Components.Web.MouseEventArgs arg codeActionName: WorkspacesSR.FormatGenerate_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task GenerateAsyncEventHandler_NoCodeBlock() { var input = """ @@ -284,7 +284,7 @@ private Task DoesNotExist(MouseEventArgs args) await VerifyCodeActionAsync(input, expected, WorkspacesSR.FormatGenerate_Async_Event_Handler_Title("DoesNotExist")); } - [FuseFact(Skip = "Need to map uri back to source generated document")] + [Fact(Skip = "Need to map uri back to source generated document")] public async Task GenerateAsyncEventHandler_CodeBlock() { var input = """ diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/PromoteUsingDirectiveTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/PromoteUsingDirectiveTests.cs index 7a4f1493085..a340af3556d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/PromoteUsingDirectiveTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/PromoteUsingDirectiveTests.cs @@ -3,15 +3,15 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Razor.Protocol; +using Xunit; using Xunit.Abstractions; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class PromoteUsingDirectiveTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class PromoteUsingDirectiveTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task PromoteUsingDirective() { await VerifyCodeActionAsync( @@ -35,7 +35,7 @@ @using System """)]); } - [FuseFact] + [Fact] public async Task Indented() { await VerifyCodeActionAsync( @@ -63,7 +63,7 @@ @using System """)]); } - [FuseFact] + [Fact] public async Task Mvc() { await VerifyCodeActionAsync( @@ -88,7 +88,7 @@ @using System """)]); } - [FuseFact] + [Fact] public async Task ExistingImports() { await VerifyCodeActionAsync( @@ -119,7 +119,7 @@ @using System """)]); } - [FuseFact] + [Fact] public async Task ExistingImports_BlankLineAtEnd() { await VerifyCodeActionAsync( @@ -151,7 +151,7 @@ @using System """)]); } - [FuseFact] + [Fact] public async Task ExistingImports_WhitespaceLineAtEnd() { await VerifyCodeActionAsync( diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/TypeAccessibilityTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/TypeAccessibilityTests.cs index 6dbed76fa6c..de16f40be64 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/TypeAccessibilityTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/TypeAccessibilityTests.cs @@ -2,14 +2,14 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; +using Xunit; using Xunit.Abstractions; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class TypeAccessibilityTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class TypeAccessibilityTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task FixCasing() { await VerifyCodeActionAsync( @@ -26,7 +26,7 @@ await VerifyCodeActionAsync( codeActionName: "EditForm"); } - [FuseFact] + [Fact] public async Task FullyQualify() { await VerifyCodeActionAsync( @@ -43,7 +43,7 @@ await VerifyCodeActionAsync( codeActionName: "Microsoft.AspNetCore.Components.Sections.SectionOutlet"); } - [FuseFact] + [Fact] public async Task AddUsing() { await VerifyCodeActionAsync( @@ -61,7 +61,7 @@ @using Microsoft.AspNetCore.Components.Sections codeActionName: "@using Microsoft.AspNetCore.Components.Sections"); } - [FuseFact] + [Fact] public async Task AddUsing_FixTypo() { await VerifyCodeActionAsync( diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/WrapAttributeTests.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/WrapAttributeTests.cs index 5c271bcdede..3f46765f28d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/WrapAttributeTests.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CodeActions/WrapAttributeTests.cs @@ -2,15 +2,15 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Razor.Protocol; +using Xunit; using Xunit.Abstractions; namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CodeActions; -public class WrapAttributeTests(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(context, testOutputHelper) +public class WrapAttributeTests(ITestOutputHelper testOutputHelper) : CohostCodeActionsEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task WrapAttributes() { await VerifyCodeActionAsync( @@ -35,7 +35,7 @@ await VerifyCodeActionAsync( codeActionName: LanguageServerConstants.CodeActions.WrapAttributes); } - [FuseFact] + [Fact] public async Task Component() { await VerifyCodeActionAsync( @@ -56,7 +56,7 @@ await VerifyCodeActionAsync( codeActionName: LanguageServerConstants.CodeActions.WrapAttributes); } - [FuseFact] + [Fact] public async Task Whitespace() { await VerifyCodeActionAsync( @@ -75,7 +75,7 @@ await VerifyCodeActionAsync( codeActionName: LanguageServerConstants.CodeActions.WrapAttributes); } - [FuseFact] + [Fact] public async Task MultiLine() { await VerifyCodeActionAsync( @@ -89,7 +89,7 @@ await VerifyCodeActionAsync( codeActionName: LanguageServerConstants.CodeActions.WrapAttributes); } - [FuseFact] + [Fact] public async Task OneAttribute() { await VerifyCodeActionAsync( 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..2858bbb1e0d 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 @@ -26,9 +26,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostDocumentCompletionEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostDocumentCompletionEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task CSharpInEmptyExplicitStatement() { await VerifyCompletionListAsync( @@ -49,7 +49,7 @@ The end. expectedItemLabels: ["var", "char", "DateTime", "Exception"]); } - [FuseFact] + [Fact] public async Task CSharpClassesAtTransition() { await VerifyCompletionListAsync( @@ -69,7 +69,7 @@ The end. expectedItemLabels: ["char", "DateTime", "Exception"]); } - [FuseFact(Skip = "Can't modify a generated document to apply '.' character")] + [Fact(Skip = "Can't modify a generated document to apply '.' character")] public async Task CSharpClassMembersAtProvisionalCompletion() { await VerifyCompletionListAsync( @@ -89,7 +89,7 @@ The end. expectedItemLabels: ["DaysInMonth", "IsLeapYear", "Now"]); } - [FuseFact(Skip = "Can't modify a generated document to apply '.' character")] + [Fact(Skip = "Can't modify a generated document to apply '.' character")] public async Task CSharpClassesInCodeBlock() { await VerifyCompletionListAsync( @@ -111,7 +111,7 @@ The end. expectedItemLabels: ["char", "DateTime", "Exception"]); } - [FuseFact] + [Fact] public async Task CSharpClassMembersInCodeBlock() { await VerifyCompletionListAsync( @@ -138,7 +138,7 @@ The end. expectedItemLabels: ["DaysInMonth", "IsLeapYear", "Now"]); } - [FuseFact] + [Fact] public async Task CSharpOverrideMethods() { await VerifyCompletionListAsync( @@ -161,7 +161,7 @@ The end. } // Tests MarkupTransitionCompletionItemProvider - [FuseFact] + [Fact] public async Task CSharpMarkupTransitionAndTagHelpersInCodeBlock() { await VerifyCompletionListAsync( @@ -189,7 +189,7 @@ The end. delegatedItemLabels: ["div"]); } - [FuseFact] + [Fact] public async Task RazorDirectives() { var expectedDirectiveLabels = new string[] @@ -229,7 +229,7 @@ The end. expectedItemLabels: expectedLabels); } - [FuseFact] + [Fact] public async Task ElementNameTagHelpersCompletion() { await VerifyCompletionListAsync( @@ -250,7 +250,7 @@ The end. delegatedItemLabels: ["div"]); } - [FuseFact] + [Fact] public async Task HtmlElementNamesAndTagHelpersCompletion() { await VerifyCompletionListAsync( @@ -271,7 +271,7 @@ The end. delegatedItemLabels: ["div", "h1"]); } - [FuseFact] + [Fact] public async Task HtmlElementNamesAndTagHelpersCompletion_EndOfDocument() { await VerifyCompletionListAsync( @@ -291,7 +291,7 @@ This is a Razor document. unexpectedItemLabels: ["snippet1", "snippet2"]); } - [FuseFact] + [Fact] public async Task HtmlElementDoNotCommitWithSpace() { await VerifyCompletionListAsync( @@ -314,7 +314,7 @@ The end. commitElementsWithSpace: false); } - [FuseFact] + [Fact] public async Task HtmlSnippetsCompletion() { await VerifyCompletionListAsync( @@ -336,7 +336,7 @@ The end. snippetLabels: ["snippet1", "snippet2"]); } - [FuseFact] + [Fact] public async Task HtmlSnippetsCompletion_EmptyDocument() { await VerifyCompletionListAsync( @@ -354,7 +354,7 @@ await VerifyCompletionListAsync( snippetLabels: ["snippet1", "snippet2"]); } - [FuseFact] + [Fact] public async Task HtmlSnippetsCompletion_WhitespaceOnlyDocument1() { await VerifyCompletionListAsync( @@ -373,7 +373,7 @@ await VerifyCompletionListAsync( snippetLabels: ["snippet1", "snippet2"]); } - [FuseFact] + [Fact] public async Task HtmlSnippetsCompletion_WhitespaceOnlyDocument2() { await VerifyCompletionListAsync( @@ -392,7 +392,7 @@ await VerifyCompletionListAsync( snippetLabels: ["snippet1", "snippet2"]); } - [FuseFact] + [Fact] public async Task HtmlSnippetsCompletion_NotInStartTag() { await VerifyCompletionListAsync( @@ -416,7 +416,7 @@ The end. } // Tests HTML attributes and DirectiveAttributeTransitionCompletionItemProvider - [FuseFact] + [Fact] public async Task HtmlAndDirectiveAttributeTransitionNamesCompletion() { await VerifyCompletionListAsync( @@ -438,7 +438,7 @@ The end. } // Tests HTML attributes and DirectiveAttributeCompletionItemProvider - [FuseFact] + [Fact] public async Task HtmlAndDirectiveAttributeNamesCompletion() { await VerifyCompletionListAsync( @@ -460,7 +460,7 @@ The end. } // Tests HTML attributes and DirectiveAttributeParameterCompletionItemProvider - [FuseFact] + [Fact] public async Task HtmlAndDirectiveAttributeParameterNamesCompletion() { await VerifyCompletionListAsync( @@ -481,7 +481,7 @@ The end. delegatedItemLabels: ["style", "dir"]); } - [FuseFact] + [Fact] public async Task HtmlAttributeNamesAndTagHelpersCompletion() { await VerifyCompletionListAsync( @@ -502,7 +502,7 @@ The end. delegatedItemLabels: ["style", "dir"]); } - [FuseFact] + [Fact] public async Task HtmlAttributeNamesAndTagHelpersCompletion_EndOfDocument() { await VerifyCompletionListAsync( @@ -521,7 +521,7 @@ This is a Razor document. delegatedItemLabels: ["style", "dir"]); } - [FuseFact] + [Fact] public async Task TagHelperAttributes_NoAutoInsertQuotes_Completion() { await VerifyCompletionListAsync( @@ -554,8 +554,6 @@ private async Task VerifyCompletionListAsync( bool autoInsertAttributeQuotes = true, bool commitElementsWithSpace = true) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var sourceText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentHighlightEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentHighlightEndpointTest.cs index a92c89c6d2c..ce044474c00 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentHighlightEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentHighlightEndpointTest.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; @@ -15,9 +14,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostDocumentHighlightEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostDocumentHighlightEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task Local() { var input = """ @@ -33,7 +32,7 @@ public async Task Local() await VerifyDocumentHighlightsAsync(input); } - [FuseFact] + [Fact] public async Task Method() { var input = """ @@ -51,7 +50,7 @@ public async Task Method() await VerifyDocumentHighlightsAsync(input); } - [FuseFact] + [Fact] public async Task AttributeToField() { var input = """ @@ -69,7 +68,7 @@ public async Task AttributeToField() await VerifyDocumentHighlightsAsync(input); } - [FuseFact] + [Fact] public async Task FieldToAttribute() { var input = """ @@ -87,7 +86,7 @@ public async Task FieldToAttribute() await VerifyDocumentHighlightsAsync(input); } - [FuseFact] + [Fact] public async Task Html() { var input = """ @@ -105,7 +104,7 @@ public async Task Html() await VerifyDocumentHighlightsAsync(input, htmlResponse: [new DocumentHighlight()]); } - [FuseFact] + [Fact] public async Task Razor() { var input = """ @@ -125,7 +124,7 @@ public async Task Razor() await VerifyDocumentHighlightsAsync(input); } - [FuseFact] + [Fact] public async Task Inject() { var input = """ @@ -147,8 +146,6 @@ @inject [|IDis$$posable|] Disposable private async Task VerifyDocumentHighlightsAsync(string input, DocumentHighlight[]? htmlResponse = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetPositionAndSpans(input, out var source, out int cursorPosition, out ImmutableArray spans); var document = CreateProjectAndRazorDocument(source); var inputText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs index 054aa27c510..7b67e6b363d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs @@ -16,9 +16,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostDocumentPullDiagnosticsTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostDocumentPullDiagnosticsTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public Task CSharp() => VerifyDiagnosticsAsync("""
@@ -32,7 +32,7 @@ public void IJustMetYou() } """); - [FuseFact] + [Fact] public Task Razor() => VerifyDiagnosticsAsync("""
@@ -42,7 +42,7 @@ public Task Razor()
"""); - [FuseFact] + [Fact] public Task Html() { TestCode input = """ @@ -67,7 +67,7 @@ public Task Html() }]); } - [FuseFact] + [Fact] public Task FilterEscapedAtFromCss() { TestCode input = """ @@ -108,7 +108,7 @@ public Task FilterEscapedAtFromCss() }]); } - [FuseFact] + [Fact] public Task CombinedAndNestedDiagnostics() => VerifyDiagnosticsAsync(""" @using System.Threading.Tasks; @@ -136,7 +136,7 @@ public void IJustMetYou() """); - [FuseFact] + [Fact] public Task TODOComments() => VerifyDiagnosticsAsync(""" @using System.Threading.Tasks; @@ -153,8 +153,6 @@ public Task TODOComments() private async Task VerifyDiagnosticsAsync(TestCode input, VSInternalDiagnosticReport[]? htmlResponse = null, bool taskListRequest = false) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text, createSeparateRemoteAndLocalWorkspaces: true); var inputText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSpellCheckEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSpellCheckEndpointTest.cs index f56bf83fe15..dc782be62ed 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSpellCheckEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSpellCheckEndpointTest.cs @@ -13,9 +13,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostDocumentSpellCheckEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostDocumentSpellCheckEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task Handle() { var input = """ @@ -57,8 +57,6 @@ Eat more chickin. private async Task VerifySpellCheckableRangesAsync(TestCode input) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var sourceText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSymbolEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSymbolEndpointTest.cs index e6cb051bed1..a9b9b09f359 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSymbolEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentSymbolEndpointTest.cs @@ -14,9 +14,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostDocumentSymbolEndpointTest(FuseTestContext context, ITestOutputHelper testOutput) : CohostEndpointTestBase(testOutput), IClassFixture +public class CohostDocumentSymbolEndpointTest(ITestOutputHelper testOutput) : CohostEndpointTestBase(testOutput) { - [FuseTheory] + [Theory] [CombinatorialData] public Task DocumentSymbols_CSharpClassWithMethods(bool hierarchical) => VerifyDocumentSymbolsAsync( @@ -43,7 +43,7 @@ class {|SomeProject.File1.C:C|} """, hierarchical); - [FuseTheory] + [Theory] [CombinatorialData] public Task DocumentSymbols_CSharpMethods(bool hierarchical) => VerifyDocumentSymbolsAsync( @@ -69,8 +69,6 @@ public Task DocumentSymbols_CSharpMethods(bool hierarchical) private async Task VerifyDocumentSymbolsAsync(string input, bool hierarchical = false) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetSpans(input, out input, out ImmutableDictionary> spansDict); var document = CreateProjectAndRazorDocument(input); 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 e08fccbd385..786dbc5e5ff 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 @@ -15,9 +15,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostFindAllReferencesEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostFindAllReferencesEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseTheory] + [Theory] [CombinatorialData] public Task FindCSharpMember(bool supportsVSExtensions) => VerifyFindAllReferencesAsync(""" @@ -36,7 +36,7 @@ string M() """, supportsVSExtensions); - [FuseTheory] + [Theory] [CombinatorialData] public async Task ComponentAttribute(bool supportsVSExtensions) { @@ -60,7 +60,7 @@ await VerifyFindAllReferencesAsync(input, supportsVSExtensions, (FilePath("SurveyPrompt.razor"), surveyPrompt)); } - [FuseTheory] + [Theory] [CombinatorialData] public async Task OtherCSharpFile(bool supportsVSExtensions) { @@ -92,8 +92,6 @@ await VerifyFindAllReferencesAsync(input, supportsVSExtensions, private async Task VerifyFindAllReferencesAsync(TestCode input, bool supportsVSExtensions, params (string fileName, TestCode testCode)[]? additionalFiles) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - UpdateClientLSPInitializationOptions(c => { c.ClientCapabilities.SupportsVisualStudioExtensions = supportsVSExtensions; 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..f0a27961df6 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 @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -17,7 +16,7 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostFoldingRangeEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostFoldingRangeEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { [FuseFact(Skip = "https://github.com/dotnet/razor/issues/10860")] public Task IfStatements() @@ -40,14 +39,14 @@ Hello World }|] """); - [FuseFact] + [Fact] public Task LockStatement() => VerifyFoldingRangesAsync(""" @lock (new object()) {[| }|] """); - [FuseFact] + [Fact] public Task UsingStatement() => VerifyFoldingRangesAsync(""" @using (new object()) {[| @@ -71,7 +70,7 @@ Goodbye World """); - [FuseFact] + [Fact] public Task Usings() => VerifyFoldingRangesAsync(""" @using System[| @@ -86,7 +85,7 @@ @using System.CodeDom|]

hello!

"""); - [FuseFact] + [Fact] public Task CSharpStatement() => VerifyFoldingRangesAsync("""

hello!

@@ -101,7 +100,7 @@ public Task CSharpStatement()

hello!

"""); - [FuseFact] + [Fact] public Task CSharpStatement_Nested() => VerifyFoldingRangesAsync("""

hello!

@@ -120,7 +119,7 @@ public Task CSharpStatement_Nested()

hello!

"""); - [FuseFact] + [Fact] public Task CSharpStatement_NotSingleLine() => VerifyFoldingRangesAsync("""

hello!

@@ -130,7 +129,7 @@ public Task CSharpStatement_NotSingleLine()

hello!

"""); - [FuseFact] + [Fact] public Task CodeBlock() => VerifyFoldingRangesAsync("""

hello!

@@ -142,7 +141,7 @@ public Task CodeBlock()

hello!

"""); - [FuseFact] + [Fact] public Task CodeBlock_Mvc() => VerifyFoldingRangesAsync("""

hello!

@@ -155,7 +154,7 @@ public Task CodeBlock_Mvc() """, fileKind: FileKinds.Legacy); - [FuseFact] + [Fact] public Task Section() => VerifyFoldingRangesAsync("""

hello!

@@ -168,7 +167,7 @@ @section Hello {[| """, fileKind: FileKinds.Legacy); - [FuseFact] + [Fact] public Task Section_Invalid() => VerifyFoldingRangesAsync("""

hello!

@@ -181,7 +180,7 @@ public Task Section_Invalid() """, fileKind: FileKinds.Legacy); - [FuseFact] + [Fact] public Task CSharpCodeInCodeBlocks() => VerifyFoldingRangesAsync("""
@@ -196,7 +195,7 @@ public void M() {[| }|] """); - [FuseFact] + [Fact] public Task HtmlAndCSharp() => VerifyFoldingRangesAsync("""
{|html: @@ -217,8 +216,6 @@ public void M() {[| private async Task VerifyFoldingRangesAsync(string input, string? fileKind = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetSpans(input, out var source, out ImmutableDictionary> spans); var document = CreateProjectAndRazorDocument(source, fileKind); var inputText = await document.GetTextAsync(DisposalToken); 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 9ab960df2b0..f434ea0af4e 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 @@ -19,9 +19,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostGoToDefinitionEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostGoToDefinitionEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task CSharp_Method() { var input = """ @@ -40,7 +40,7 @@ public async Task CSharp_Method() await VerifyGoToDefinitionAsync(input); } - [FuseFact] + [Fact] public async Task CSharp_Local() { var input = """ @@ -61,7 +61,7 @@ string GetX() await VerifyGoToDefinitionAsync(input); } - [FuseFact] + [Fact] public async Task CSharp_MetadataReference() { var input = """ @@ -87,7 +87,7 @@ public async Task CSharp_MetadataReference() Assert.Contains("public sealed class String", line); } - [FuseTheory] + [Theory] [InlineData("$$IncrementCount")] [InlineData("In$$crementCount")] [InlineData("IncrementCount$$")] @@ -107,7 +107,7 @@ public async Task Attribute_SameFile(string method) await VerifyGoToDefinitionAsync(input, FileKinds.Component); } - [FuseFact] + [Fact] public async Task AttributeValue_BindAfter() { var input = """ @@ -126,7 +126,7 @@ public async Task AttributeValue_BindAfter() await VerifyGoToDefinitionAsync(input, FileKinds.Component); } - [FuseFact] + [Fact] public async Task Component() { TestCode input = """ @@ -157,7 +157,7 @@ public async Task Component() Assert.Equal(range, location.Range); } - [FuseTheory] + [Theory] [InlineData("Ti$$tle")] [InlineData("$$@bind-Title")] [InlineData("@$$bind-Title")] @@ -203,7 +203,7 @@ @namespace SomeProject Assert.Equal(range, location.Range); } - [FuseFact] + [Fact] public async Task Html() { // This really just validates Uri remapping, the actual response is largely arbitrary @@ -238,8 +238,6 @@ private static string FileName(string projectRelativeFileName) private async Task VerifyGoToDefinitionAsync(TestCode input, string? fileKind = null, SumType? htmlResponse = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text, fileKind); var result = await GetGoToDefinitionResultCoreAsync(document, input, htmlResponse); @@ -259,8 +257,6 @@ private async Task VerifyGoToDefinitionAsync(TestCode input, string? fileKind = private async Task?> GetGoToDefinitionResultAsync( TestCode input, string? fileKind = null, params (string fileName, string contents)[]? additionalFiles) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text, fileKind, additionalFiles); return await GetGoToDefinitionResultCoreAsync(document, input, htmlResponse: null); } 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 7bc1983423e..5f157074921 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 @@ -17,9 +17,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostGoToImplementationEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostGoToImplementationEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task CSharp_Method() { var input = """ @@ -40,7 +40,7 @@ public async Task CSharp_Method() await VerifyCSharpGoToImplementationAsync(input); } - [FuseFact] + [Fact] public async Task CSharp_Field() { var input = """ @@ -64,7 +64,7 @@ string GetX() await VerifyCSharpGoToImplementationAsync(input); } - [FuseFact] + [Fact] public async Task CSharp_Multiple() { var input = """ @@ -85,7 +85,7 @@ void M(Ba$$se b) await VerifyCSharpGoToImplementationAsync(input); } - [FuseFact] + [Fact] public async Task Html() { // This really just validates Uri remapping, the actual response is largely arbitrary @@ -119,8 +119,6 @@ public async Task Html() private async Task VerifyCSharpGoToImplementationAsync(TestCode input) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var requestInvoker = new TestLSPRequestInvoker(); @@ -130,8 +128,6 @@ private async Task VerifyCSharpGoToImplementationAsync(TestCode input) private async Task VerifyGoToImplementationResultAsync(TestCode input, TextDocument document, TestLSPRequestInvoker requestInvoker) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - await VerifyGoToImplementationResultCoreAsync(input, document, requestInvoker); } 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..0d10af64354 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 @@ -16,9 +16,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; using static HoverAssertions; -public class CohostHoverEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostHoverEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task Razor() { TestCode code = """ @@ -53,7 +53,7 @@ await VerifyHoverAsync(code, async (hover, document) => }); } - [FuseFact] + [Fact] public async Task Html() { TestCode code = """ @@ -73,7 +73,7 @@ public async Task Html() await VerifyHoverAsync(code, htmlResponse, h => Assert.Same(htmlResponse, h)); } - [FuseFact] + [Fact] public async Task CSharp() { TestCode code = """ @@ -106,7 +106,7 @@ await VerifyHoverAsync(code, async (hover, document) => }); } - [FuseFact] + [Fact] public async Task ComponentAttribute() { // Component attributes are within HTML but actually map to C#. @@ -145,7 +145,7 @@ await VerifyHoverAsync(code, async (hover, document) => }); } - [FuseFact] + [Fact] public async Task Component_WithCallbacks() { TestCode code = """ @@ -185,8 +185,6 @@ await VerifyHoverAsync(code, async (hover, document) => private async Task VerifyHoverAsync(TestCode input, Func verifyHover) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var result = await GetHoverResultAsync(document, input); @@ -199,8 +197,6 @@ private async Task VerifyHoverAsync(TestCode input, Func verifyHover) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var result = await GetHoverResultAsync(document, input, htmlResponse); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlayHintEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlayHintEndpointTest.cs index a4dd2e0ddfb..f04b05a81fa 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlayHintEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlayHintEndpointTest.cs @@ -7,7 +7,6 @@ using System.Text.Json; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Testing; @@ -19,9 +18,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostInlayHintEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostInlayHintEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public Task InlayHints() => VerifyInlayHintsAsync( input: """ @@ -63,7 +62,7 @@ private void M(string thisIsMyString) """); - [FuseFact] + [Fact] public Task InlayHints_DisplayAllOverride() => VerifyInlayHintsAsync( input: """ @@ -106,7 +105,7 @@ private void M(string thisIsMyString) """, displayAllOverride: true); - [FuseFact] + [Fact] public Task InlayHints_ComponentAttributes() => VerifyInlayHintsAsync( input: """ @@ -129,14 +128,12 @@ public Task InlayHints_ComponentAttributes() """); - [FuseTheory] + [Theory] [InlineData(0, 0, 0, 20)] [InlineData(0, 0, 2, 0)] [InlineData(2, 0, 4, 0)] public async Task InlayHints_InvalidRange(int startLine, int starChar, int endLine, int endChar) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var input = """
"""; @@ -157,8 +154,6 @@ public async Task InlayHints_InvalidRange(int startLine, int starChar, int endLi private async Task VerifyInlayHintsAsync(string input, Dictionary toolTipMap, string output, bool displayAllOverride = false) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetSpans(input, out input, out ImmutableDictionary> spansDict); var document = CreateProjectAndRazorDocument(input); var inputText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlineCompletionEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlineCompletionEndpointTest.cs index 597e8d0e4bb..1e2f6870928 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlineCompletionEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlineCompletionEndpointTest.cs @@ -24,9 +24,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostInlineCompletionEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostInlineCompletionEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact(Skip = "Cannot edit source generated documents")] + [Fact(Skip = "Cannot edit source generated documents")] public Task Constructor() => VerifyInlineCompletionAsync( input: """ @@ -49,7 +49,7 @@ public File1() } """); - [FuseFact(Skip = "Cannot edit source generated documents")] + [Fact(Skip = "Cannot edit source generated documents")] public Task Constructor_SmallIndent() => VerifyInlineCompletionAsync( input: """ @@ -73,7 +73,7 @@ public File1() """, tabSize: 2); - [FuseFact] + [Fact] public Task InHtml_DoesNothing() => VerifyInlineCompletionAsync( input: """ @@ -82,8 +82,6 @@ public Task InHtml_DoesNothing() private async Task VerifyInlineCompletionAsync(TestCode input, string? output = null, int tabSize = 4) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text, createSeparateRemoteAndLocalWorkspaces: true); var inputText = await document.GetTextAsync(DisposalToken); var position = inputText.GetLinePosition(input.Position); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostLinkedEditingRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostLinkedEditingRangeEndpointTest.cs index b4a3e592230..28c05827166 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostLinkedEditingRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostLinkedEditingRangeEndpointTest.cs @@ -3,7 +3,6 @@ using System.Collections.Immutable; using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Razor.LinkedEditingRange; using Microsoft.CodeAnalysis.Testing; @@ -14,9 +13,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostLinkedEditingRangeEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostLinkedEditingRangeEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseTheory] + [Theory] [InlineData("$$PageTitle", "PageTitle")] [InlineData("Page$$Title", "PageTitle")] [InlineData("PageTitle$$", "PageTitle")] @@ -36,7 +35,7 @@ The end. await VerifyLinkedEditingRangeAsync(input); } - [FuseTheory] + [Theory] [InlineData("$$div")] [InlineData("di$$v")] [InlineData("div$$")] @@ -55,7 +54,7 @@ The end. await VerifyLinkedEditingRangeAsync(input); } - [FuseTheory] + [Theory] [InlineData("$$div")] [InlineData("di$$v")] [InlineData("div$$")] @@ -74,7 +73,7 @@ The end. await VerifyLinkedEditingRangeAsync(input); } - [FuseFact] + [Fact] public async Task Html_EndTag_BeforeSlash() { var input = $""" @@ -90,7 +89,7 @@ The end. await VerifyLinkedEditingRangeAsync(input); } - [FuseFact] + [Fact] public async Task Html_NotATag() { var input = $""" @@ -106,7 +105,7 @@ The end. await VerifyLinkedEditingRangeAsync(input); } - [FuseFact] + [Fact] public async Task Html_NestedTags_Outer() { var input = $""" @@ -124,7 +123,7 @@ The end. await VerifyLinkedEditingRangeAsync(input); } - [FuseFact] + [Fact] public async Task Html_NestedTags_Inner() { var input = $""" @@ -142,7 +141,7 @@ The end. await VerifyLinkedEditingRangeAsync(input); } - [FuseFact] + [Fact] public async Task Html_SelfClosingTag() { var input = $""" @@ -159,8 +158,6 @@ The end. private async Task VerifyLinkedEditingRangeAsync(string input) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetPositionAndSpans(input, out input, out int cursorPosition, out ImmutableArray spans); var document = CreateProjectAndRazorDocument(input); var sourceText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnAutoInsertEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnAutoInsertEndpointTest.cs index 3da015a7dd4..8496691b7a9 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnAutoInsertEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnAutoInsertEndpointTest.cs @@ -17,9 +17,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostOnAutoInsertEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostOnAutoInsertEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseTheory] + [Theory] [InlineData("PageTitle")] [InlineData("div")] [InlineData("text")] @@ -43,7 +43,7 @@ The end. triggerCharacter: ">"); } - [FuseTheory] + [Theory] [InlineData("PageTitle")] [InlineData("div")] [InlineData("text")] @@ -62,7 +62,7 @@ The end. autoClosingTags: false); } - [FuseFact] + [Fact] public async Task AttributeQuotes() { await VerifyOnAutoInsertAsync( @@ -84,7 +84,7 @@ The end. delegatedResponseText: "\"$0\""); } - [FuseFact] + [Fact] public async Task CSharp_OnForwardSlash() { await VerifyOnAutoInsertAsync( @@ -105,7 +105,7 @@ void TestMethod() {} triggerCharacter: "/"); } - [FuseFact] + [Fact] public async Task DoNotAutoInsertCSharp_OnForwardSlashWithFormatOnTypeDisabled() { await VerifyOnAutoInsertAsync( @@ -120,7 +120,7 @@ void TestMethod() {} formatOnType: false); } - [FuseFact] + [Fact] public async Task CSharp_OnEnter() { await VerifyOnAutoInsertAsync( @@ -159,7 +159,7 @@ void TestMethod() triggerCharacter: "\n"); } - [FuseFact] + [Fact] public async Task CSharp_OnEnter_TwoSpaceIndent() { await VerifyOnAutoInsertAsync( @@ -181,7 +181,7 @@ void TestMethod() tabSize: 2); } - [FuseFact] + [Fact] public async Task CSharp_OnEnter_UseTabs() { const char tab = '\t'; @@ -214,8 +214,6 @@ private async Task VerifyOnAutoInsertAsync( bool formatOnType = true, bool autoClosingTags = true) { - UpdateClientInitializationOptions(opt => opt with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var sourceText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs index b6dd87e2006..e8d56b834e9 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostOnTypeFormattingEndpointTest.cs @@ -19,10 +19,10 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; [Collection(HtmlFormattingCollection.Name)] -public class CohostOnTypeFormattingEndpointTest(FuseTestContext context, HtmlFormattingFixture htmlFormattingFixture, ITestOutputHelper testOutputHelper) - : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostOnTypeFormattingEndpointTest(HtmlFormattingFixture htmlFormattingFixture, ITestOutputHelper testOutputHelper) + : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task InvalidTrigger() { await VerifyOnTypeFormattingAsync( @@ -39,7 +39,7 @@ await VerifyOnTypeFormattingAsync( triggerCharacter: 'h'); } - [FuseFact] + [Fact] public async Task CSharp_InvalidTrigger() { await VerifyOnTypeFormattingAsync( @@ -56,7 +56,7 @@ await VerifyOnTypeFormattingAsync( triggerCharacter: '\n'); } - [FuseFact] + [Fact] public async Task CSharp() { await VerifyOnTypeFormattingAsync( @@ -73,7 +73,7 @@ await VerifyOnTypeFormattingAsync( triggerCharacter: '}'); } - [FuseFact] + [Fact] public async Task FormatsSimpleHtmlTag_OnType() { await VerifyOnTypeFormattingAsync( @@ -103,8 +103,6 @@ await VerifyOnTypeFormattingAsync( private async Task VerifyOnTypeFormattingAsync(TestCode input, string expected, char triggerCharacter, bool html = false) { - UpdateClientInitializationOptions(opt => opt with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var inputText = await document.GetTextAsync(DisposalToken); var position = inputText.GetPosition(input.Position); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs index cbf3021c591..26879cba065 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRangeFormattingEndpointTest.cs @@ -19,10 +19,10 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; [Collection(HtmlFormattingCollection.Name)] -public class CohostRangeFormattingEndpointTest(FuseTestContext context, HtmlFormattingFixture htmlFormattingFixture, ITestOutputHelper testOutputHelper) - : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostRangeFormattingEndpointTest(HtmlFormattingFixture htmlFormattingFixture, ITestOutputHelper testOutputHelper) + : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public Task RangeFormatting() => VerifyRangeFormattingAsync( input: """ @@ -102,8 +102,6 @@ private void M(string thisIsMyString) private async Task VerifyRangeFormattingAsync(TestCode input, string expected) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var inputText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRenameEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRenameEndpointTest.cs index 9263e015e92..cb1dd8c0ace 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRenameEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRenameEndpointTest.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Testing; @@ -17,9 +16,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostRenameEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostRenameEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact(Skip = "Cannot edit source generated documents")] + [Fact(Skip = "Cannot edit source generated documents")] public Task CSharp_Method() => VerifyRenamesAsync( input: """ @@ -54,7 +53,7 @@ public string CallThisFunction() The end. """); - [FuseTheory(Skip = "Cannot edit source generated documents")] + [Theory(Skip = "Cannot edit source generated documents")] [InlineData("$$Component")] [InlineData("Com$$ponent")] [InlineData("Component$$")] @@ -102,7 +101,7 @@ The end. """, renames: [("Component.razor", "DifferentName.razor")]); - [FuseTheory(Skip = "Cannot edit source generated documents")] + [Theory(Skip = "Cannot edit source generated documents")] [InlineData("$$Component")] [InlineData("Com$$ponent")] [InlineData("Component$$")] @@ -150,7 +149,7 @@ The end. """, renames: [("Component.razor", "DifferentName.razor")]); - [FuseFact] + [Fact] public Task Mvc() => VerifyRenamesAsync( input: """ @@ -169,8 +168,6 @@ The end. private async Task VerifyRenamesAsync(string input, string newName, string expected, string? fileKind = null, (string fileName, string contents)[]? additionalFiles = null, (string oldName, string newName)[]? renames = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetPosition(input, out var source, out var cursorPosition); var document = CreateProjectAndRazorDocument(source, fileKind, additionalFiles); var inputText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs index d8c519b7016..84211d8db0c 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Semantic; using Microsoft.AspNetCore.Razor.PooledObjects; using Microsoft.AspNetCore.Razor.Telemetry; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Razor.Settings; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Razor.Settings; @@ -19,9 +18,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostSemanticTokensRangeEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostSemanticTokensRangeEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseTheory] + [Theory] [CombinatorialData] public async Task Razor(bool colorBackground, bool precise) { @@ -89,7 +88,7 @@ @section MySection { await VerifySemanticTokensAsync(input, colorBackground, precise, fileKind: FileKinds.Legacy); } - [FuseTheory] + [Theory] [CombinatorialData] public async Task Legacy_Compatibility(bool colorBackground, bool precise) { @@ -116,8 +115,6 @@ public void M() private async Task VerifySemanticTokensAsync(string input, bool colorBackground, bool precise, string? fileKind = null, [CallerMemberName] string? testName = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input, fileKind); var sourceText = await document.GetTextAsync(DisposalToken); @@ -221,7 +218,7 @@ private static string GetTokenModifierString(int tokenModifiers) var modifiersBuilder = ArrayBuilder.GetInstance(); for (var i = 0; i < modifiers.Length; i++) { - if ((tokenModifiers & (1 << i % 32)) != 0) + if ((tokenModifiers & (1 << (i % 32))) != 0) { modifiersBuilder.Add(modifiers[i]); } diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSignatureHelpEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSignatureHelpEndpointTest.cs index 73e5dd9890b..c3e1f72cc4d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSignatureHelpEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSignatureHelpEndpointTest.cs @@ -16,9 +16,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostSignatureHelpEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostSignatureHelpEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task CSharpMethodCSharp() { var input = """ @@ -37,7 +37,7 @@ void Act() await VerifySignatureHelpAsync(input, "string M1(int i)"); } - [FuseFact] + [Fact] public async Task CSharpMethodInRazor() { var input = """ @@ -51,7 +51,7 @@ public async Task CSharpMethodInRazor() await VerifySignatureHelpAsync(input, "string GetDiv()"); } - [FuseFact] + [Fact] public async Task AutoListParamsOff_Invoked_ReturnsResult() { var input = """ @@ -70,7 +70,7 @@ void Act() await VerifySignatureHelpAsync(input, "string M1(int i)", autoListParams: false, triggerKind: SignatureHelpTriggerKind.Invoked); } - [FuseFact] + [Fact] public async Task AutoListParamsOff_NotInvoked_ReturnsNoResult() { var input = """ @@ -91,8 +91,6 @@ void Act() private async Task VerifySignatureHelpAsync(string input, string expected, bool autoListParams = true, SignatureHelpTriggerKind? triggerKind = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetPosition(input, out input, out var cursorPosition); var document = CreateProjectAndRazorDocument(input); var sourceText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostTextPresentationEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostTextPresentationEndpointTest.cs index 6963263979f..6f958670218 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostTextPresentationEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostTextPresentationEndpointTest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.ExternalAccess.Razor; using Microsoft.CodeAnalysis.Testing; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -11,9 +10,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostTextPresentationEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostTextPresentationEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task HtmlResponse_TranslatesVirtualDocumentUri() { await VerifyUriPresentationAsync( @@ -46,8 +45,6 @@ The end. private async Task VerifyUriPresentationAsync(string input, string text, string? expected, WorkspaceEdit? htmlResponse = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetSpan(input, out input, out var span); var document = CreateProjectAndRazorDocument(input); var sourceText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostUriPresentationEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostUriPresentationEndpointTest.cs index f417d3eae45..6a3d3b2e0ec 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostUriPresentationEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostUriPresentationEndpointTest.cs @@ -12,9 +12,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostUriPresentationEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostUriPresentationEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task RandomFile() { await VerifyUriPresentationAsync( @@ -33,7 +33,7 @@ The end. expected: null); } - [FuseFact] + [Fact] public async Task HtmlResponse_TranslatesVirtualDocumentUri() { var siteCssFileUriString = "file:///C:/path/to/site.css"; @@ -67,7 +67,7 @@ The end. expected: htmlTag); } - [FuseFact] + [Fact] public async Task Component() { await VerifyUriPresentationAsync( @@ -87,7 +87,7 @@ The end. expected: ""); } - [FuseFact] + [Fact] public async Task ImportsFile() { await VerifyUriPresentationAsync( @@ -104,7 +104,7 @@ The end. expected: null); } - [FuseFact] + [Fact] public async Task Html_IntoCSharp_NoTag() { var siteCssFileUriString = "file:///C:/path/to/site.css"; @@ -139,7 +139,7 @@ This is a Razor document. expected: null); } - [FuseFact] + [Fact] public async Task Component_IntoCSharp_NoTag() { await VerifyUriPresentationAsync( @@ -160,7 +160,7 @@ This is a Razor document. expected: null); } - [FuseFact] + [Fact] public async Task Component_WithChildFile() { await VerifyUriPresentationAsync( @@ -184,7 +184,7 @@ The end. expected: ""); } - [FuseFact] + [Fact] public async Task Component_WithChildFile_RazorNotFirst() { await VerifyUriPresentationAsync( @@ -208,7 +208,7 @@ The end. expected: ""); } - [FuseFact] + [Fact] public async Task Component_RequiredParameter() { await VerifyUriPresentationAsync( @@ -241,8 +241,6 @@ The end. private async Task VerifyUriPresentationAsync(string input, Uri[] uris, string? expected, WorkspaceEdit? htmlResponse = null, (string fileName, string contents)[]? additionalFiles = null) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - TestFileMarkupParser.GetSpan(input, out input, out var span); var document = CreateProjectAndRazorDocument(input, additionalFiles: additionalFiles); var sourceText = await document.GetTextAsync(DisposalToken); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostValidateBreakableRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostValidateBreakableRangeEndpointTest.cs index e1670257862..16ba6e4fff1 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostValidateBreakableRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostValidateBreakableRangeEndpointTest.cs @@ -13,9 +13,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; -public class CohostValidateBreakableRangeEndpointTest(FuseTestContext context, ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper), IClassFixture +public class CohostValidateBreakableRangeEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact] + [Fact] public async Task Handle_CSharpInHtml_ValidBreakpoint() { var input = """ @@ -31,7 +31,7 @@ public async Task Handle_CSharpInHtml_ValidBreakpoint() await VerifyBreakableRangeAsync(input); } - [FuseFact] + [Fact] public async Task Handle_CSharpInAttribute_ValidBreakpoint() { var input = """ @@ -47,7 +47,7 @@ public async Task Handle_CSharpInAttribute_ValidBreakpoint() await VerifyBreakableRangeAsync(input); } - [FuseFact] + [Fact] public async Task Handle_CSharp_ValidBreakpoint() { var input = """ @@ -61,7 +61,7 @@ public async Task Handle_CSharp_ValidBreakpoint() await VerifyBreakableRangeAsync(input); } - [FuseFact] + [Fact] public async Task Handle_CSharp_InvalidBreakpointRemoved() { var input = """ @@ -75,7 +75,7 @@ public async Task Handle_CSharp_InvalidBreakpointRemoved() await VerifyBreakableRangeAsync(input); } - [FuseFact] + [Fact] public async Task Handle_CSharp_ValidBreakpointMoved() { var input = """ @@ -90,7 +90,7 @@ public async Task Handle_CSharp_ValidBreakpointMoved() await VerifyBreakableRangeAsync(input); } - [FuseFact] + [Fact] public async Task Handle_Html_BreakpointRemoved() { var input = """ @@ -106,8 +106,6 @@ public async Task Handle_Html_BreakpointRemoved() private async Task VerifyBreakableRangeAsync(TestCode input) { - UpdateClientInitializationOptions(c => c with { ForceRuntimeCodeGeneration = context.ForceRuntimeCodeGeneration }); - var document = CreateProjectAndRazorDocument(input.Text); var inputText = await document.GetTextAsync(DisposalToken); From df746e08467762a7a6cb7189a30cc4a47d1e1e39 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 5 Mar 2025 13:45:52 +1100 Subject: [PATCH 03/14] Unskip tests that are now stable These could arguably still be "wrong" in Fuse, but since they're stable we may as well have the coverage. --- .../Cohost/CohostFoldingRangeEndpointTest.cs | 16 ++++++++-------- .../CohostSemanticTokensRangeEndpointTest.cs | 2 +- .../TestFiles/SemanticTokens/Legacy.txt | 6 +----- .../SemanticTokens/Legacy_with_background.txt | 6 +----- 4 files changed, 11 insertions(+), 19 deletions(-) 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 f0a27961df6..4dbfae089b7 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 @@ -18,7 +18,7 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; public class CohostFoldingRangeEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [FuseFact(Skip = "https://github.com/dotnet/razor/issues/10860")] + [Fact] public Task IfStatements() => VerifyFoldingRangesAsync("""
@@ -26,15 +26,15 @@ public Task IfStatements()
Hello World
- }|] -
+ } + |]
@if (true) {[|
Hello World
- }|] - + } + |] @if (true) {[| }|] """); @@ -53,7 +53,7 @@ public Task UsingStatement() }|] """); - [FuseFact(Skip = "https://github.com/dotnet/razor/issues/10860")] + [Fact] public Task IfElseStatements() => VerifyFoldingRangesAsync("""
@@ -66,8 +66,8 @@ Hello World Goodbye World
}|] - }|] -
+ } + |] """); [Fact] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs index 84211d8db0c..4ef6b836302 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostSemanticTokensRangeEndpointTest.cs @@ -60,7 +60,7 @@ public void M() await VerifySemanticTokensAsync(input, colorBackground, precise); } - [FuseTheory(Skip = "https://github.com/dotnet/razor/issues/10857 and https://github.com/dotnet/razor/issues/11329")] + [Theory] [CombinatorialData] public async Task Legacy(bool colorBackground, bool precise) { diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt index f1f0cdb3e74..ece52c1e7ba 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt @@ -4,9 +4,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 5 3 string [] ["/"] 1 0 1 razorTransition [] [@] 0 1 5 razorDirective [] [model] -0 6 8 variable [] [AppThing] -0 8 1 operator [] [.] -0 1 5 variable [] [Model] 1 0 1 razorTransition [] [@] 0 1 5 keyword [] [using] 0 6 6 namespace name [] [System] @@ -47,8 +44,7 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 1 0 1 razorTransition [] [}] 2 0 1 razorTransition [] [@] 0 1 7 razorDirective [] [section] -0 8 9 local name [] [MySection] -0 10 1 razorTransition [] [{] +0 18 1 razorTransition [] [{] 1 4 1 markupTagDelimiter [] [<] 0 1 3 markupElement [] [div] 0 3 1 markupTagDelimiter [] [>] diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt index 77227b0c3b6..ac3405ba765 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy_with_background.txt @@ -4,9 +4,6 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 0 5 3 string [razorCode] ["/"] 1 0 1 razorTransition [] [@] 0 1 5 razorDirective [] [model] -0 6 8 variable [razorCode] [AppThing] -0 8 1 operator [razorCode] [.] -0 1 5 variable [razorCode] [Model] 1 0 1 razorTransition [] [@] 0 1 5 keyword [razorCode] [using] 0 5 1 markupTextLiteral [razorCode] [ ] @@ -53,8 +50,7 @@ Line Δ, Char Δ, Length, Type, Modifier(s), Text 1 0 1 razorTransition [] [}] 2 0 1 razorTransition [] [@] 0 1 7 razorDirective [] [section] -0 8 9 local name [razorCode] [MySection] -0 10 1 razorTransition [] [{] +0 18 1 razorTransition [] [{] 1 4 1 markupTagDelimiter [] [<] 0 1 3 markupElement [] [div] 0 3 1 markupTagDelimiter [] [>] From 45d507dd955f0293b5a344d677c1a24cb407eca3 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 5 Mar 2025 14:43:50 +1100 Subject: [PATCH 04/14] Update formatting tests to not vary by FUSE More to come in a follow up here, that also changes product code --- .../Cohost/FormattingTestBase.cs | 1 - .../Formatting/FormattingTestCase.cs | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs index 6d6d75ecf9e..94999ea0e0a 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs @@ -159,7 +159,6 @@ private protected async Task RunOnTypeFormattingTestAsync( UpdateClientInitializationOptions(opt => opt with { - ForceRuntimeCodeGeneration = _context.ForceRuntimeCodeGeneration, UseNewFormattingEngine = _context.UseNewFormattingEngine }); diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs index 6540e0406dc..6163fdf39c4 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs @@ -59,6 +59,11 @@ protected override string GetSkipReason(IAttributeInfo factAttribute) return "Language server cannot run FUSE tests"; } + if (!_forceRuntimeCodeGeneration && TestMethod.TestClass.TestCollection.TestAssembly.Assembly.Name.StartsWith("Microsoft.VisualStudio.LanguageServices.Razor")) + { + return "Language services (cohost) cannot run non-FUSE tests"; + } + return base.GetSkipReason(factAttribute); } From 611dceba950bc7a98e351e68636f5a9cf7e08c91 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:32:14 +1100 Subject: [PATCH 05/14] Swap things around so FUSE tests are run by the langauge server and cohost doesn't vary --- .../Formatting_NetFx/FormattingTestBase.cs | 1 - .../Formatting/FormattingFactDiscoverer.cs | 17 +++++++++++------ .../Formatting/FormattingTestCase.cs | 10 ---------- 3 files changed, 11 insertions(+), 17 deletions(-) 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 7f21692aa88..4eed842eaec 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 @@ -197,7 +197,6 @@ private protected async Task RunOnTypeFormattingTestAsync( private (string input, string expected) ProcessFormattingContext(string input, string expected) { Assert.True(_context.CreatedByFormattingDiscoverer, "Test class is using FormattingTestContext, but not using [FormattingTestFact] or [FormattingTestTheory]"); - Assert.False(_context.ForceRuntimeCodeGeneration, "ForceRuntimeGeneration does not currently work in the language server. Creating tests for it is a false positive"); if (_context.ShouldFlipLineEndings) { diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingFactDiscoverer.cs b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingFactDiscoverer.cs index ff24b6eaf4b..b5a3f16b091 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingFactDiscoverer.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingFactDiscoverer.cs @@ -17,14 +17,19 @@ public override IEnumerable Discover(ITestFrameworkDiscoveryOpti public static IEnumerable CreateTestCases(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IMessageSink messageSink, object[]? dataRow = null) { - yield return CreateTestCase(shouldFlipLineEndings: false, forceRuntimeCodeGeneration: false, useNewFormattingEngine: false); - yield return CreateTestCase(shouldFlipLineEndings: false, forceRuntimeCodeGeneration: true, useNewFormattingEngine: false); - yield return CreateTestCase(shouldFlipLineEndings: true, forceRuntimeCodeGeneration: false, useNewFormattingEngine: false); - yield return CreateTestCase(shouldFlipLineEndings: true, forceRuntimeCodeGeneration: true, useNewFormattingEngine: false); + // Cohosting only has runtime code-gen, so the old formatting engine doesn't work with them + if (!testMethod.TestClass.TestCollection.TestAssembly.Assembly.Name.StartsWith("Microsoft.VisualStudio.LanguageServices.Razor")) + { + yield return CreateTestCase(shouldFlipLineEndings: false, forceRuntimeCodeGeneration: false, useNewFormattingEngine: false); + yield return CreateTestCase(shouldFlipLineEndings: false, forceRuntimeCodeGeneration: true, useNewFormattingEngine: false); + yield return CreateTestCase(shouldFlipLineEndings: true, forceRuntimeCodeGeneration: false, useNewFormattingEngine: false); + yield return CreateTestCase(shouldFlipLineEndings: true, forceRuntimeCodeGeneration: true, useNewFormattingEngine: false); + + yield return CreateTestCase(shouldFlipLineEndings: false, forceRuntimeCodeGeneration: false, useNewFormattingEngine: true); + yield return CreateTestCase(shouldFlipLineEndings: true, forceRuntimeCodeGeneration: false, useNewFormattingEngine: true); + } - yield return CreateTestCase(shouldFlipLineEndings: false, forceRuntimeCodeGeneration: false, useNewFormattingEngine: true); yield return CreateTestCase(shouldFlipLineEndings: false, forceRuntimeCodeGeneration: true, useNewFormattingEngine: true); - yield return CreateTestCase(shouldFlipLineEndings: true, forceRuntimeCodeGeneration: false, useNewFormattingEngine: true); yield return CreateTestCase(shouldFlipLineEndings: true, forceRuntimeCodeGeneration: true, useNewFormattingEngine: true); FormattingTestCase CreateTestCase(bool shouldFlipLineEndings, bool forceRuntimeCodeGeneration, bool useNewFormattingEngine) diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs index 6163fdf39c4..d52ca21700e 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Test.Common/Formatting/FormattingTestCase.cs @@ -54,16 +54,6 @@ protected override string GetSkipReason(IAttributeInfo factAttribute) return "Some tests cover features not supported by the old formatting engine"; } - if (_forceRuntimeCodeGeneration && TestMethod.TestClass.TestCollection.TestAssembly.Assembly.Name.StartsWith("Microsoft.AspNetCore.Razor.LanguageServer")) - { - return "Language server cannot run FUSE tests"; - } - - if (!_forceRuntimeCodeGeneration && TestMethod.TestClass.TestCollection.TestAssembly.Assembly.Name.StartsWith("Microsoft.VisualStudio.LanguageServices.Razor")) - { - return "Language services (cohost) cannot run non-FUSE tests"; - } - return base.GetSkipReason(factAttribute); } From ba309f1bd472446ca00cf423ed776cd82f1d8a2f Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:33:17 +1100 Subject: [PATCH 06/14] Cohosting is always using the new formatting engine, since its always using FUSE --- .../Remote/RemoteClientInitializationOptions.cs | 3 --- .../Initialization/RemoteLanguageServerFeatureOptions.cs | 2 +- .../Remote/RemoteServiceInvoker.cs | 1 - .../Cohost/CohostEndpointTestBase.cs | 1 - .../Cohost/FormattingTestBase.cs | 5 ----- 5 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs index aeeddb2fa7f..901d7c522de 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs @@ -25,9 +25,6 @@ internal struct RemoteClientInitializationOptions [JsonPropertyName("showAllCSharpCodeActions")] public required bool ShowAllCSharpCodeActions { get; set; } - [JsonPropertyName("useNewFormattingEngine")] - public required bool UseNewFormattingEngine { get; set; } - [JsonPropertyName("supportsSoftSelectionInCompletion")] public required bool SupportsSoftSelectionInCompletion { get; set; } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs index cb9f607c752..a9c26a4b697 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteLanguageServerFeatureOptions.cs @@ -48,7 +48,7 @@ public void SetOptions(RemoteClientInitializationOptions options) public override bool ForceRuntimeCodeGeneration => true; - public override bool UseNewFormattingEngine => _options.UseNewFormattingEngine; + public override bool UseNewFormattingEngine => true; public override bool SupportsSoftSelectionInCompletion => _options.SupportsSoftSelectionInCompletion; diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs index 29788117544..164d52ddfc7 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Remote/RemoteServiceInvoker.cs @@ -173,7 +173,6 @@ Task InitializeOOPAsync(RazorRemoteHostClient remoteClient) ReturnCodeActionAndRenamePathsWithPrefixedSlash = _languageServerFeatureOptions.ReturnCodeActionAndRenamePathsWithPrefixedSlash, SupportsFileManipulation = _languageServerFeatureOptions.SupportsFileManipulation, ShowAllCSharpCodeActions = _languageServerFeatureOptions.ShowAllCSharpCodeActions, - UseNewFormattingEngine = _languageServerFeatureOptions.UseNewFormattingEngine, SupportsSoftSelectionInCompletion = _languageServerFeatureOptions.SupportsSoftSelectionInCompletion, UseVsCodeCompletionTriggerCharacters = _languageServerFeatureOptions.UseVsCodeCompletionTriggerCharacters, }; 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 52ae085cf5c..a1ab9149eb0 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 @@ -81,7 +81,6 @@ protected override async Task InitializeAsync() ReturnCodeActionAndRenamePathsWithPrefixedSlash = false, SupportsFileManipulation = true, ShowAllCSharpCodeActions = false, - UseNewFormattingEngine = false, SupportsSoftSelectionInCompletion = true, UseVsCodeCompletionTriggerCharacters = false, }; diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs index 94999ea0e0a..e2d3e3312e1 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/FormattingTestBase.cs @@ -157,11 +157,6 @@ private protected async Task RunOnTypeFormattingTestAsync( { Assert.True(_context.CreatedByFormattingDiscoverer, "Test class is using FormattingTestContext, but not using [FormattingTestFact] or [FormattingTestTheory]"); - UpdateClientInitializationOptions(opt => opt with - { - UseNewFormattingEngine = _context.UseNewFormattingEngine - }); - if (_context.ShouldFlipLineEndings) { // flip the line endings of the stings (LF to CRLF and vice versa) and run again From d00abe84ead1f16cbc0ebdc479682b9be3e0101a Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:35:47 +1100 Subject: [PATCH 07/14] Get standard tag helpers from Basic.ReferenceAssemblies rather than a Json file --- .../Formatting_NetFx/FormattingTestBase.cs | 74 ++++++++++++++++--- 1 file changed, 64 insertions(+), 10 deletions(-) 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 4eed842eaec..601be213bfb 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 @@ -8,16 +8,21 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Basic.Reference.Assemblies; using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.IntegrationTests; using Microsoft.AspNetCore.Razor.LanguageServer.Hosting; +using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.AspNetCore.Razor.ProjectSystem; +using Microsoft.AspNetCore.Razor.Telemetry; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer; using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; +using Microsoft.AspNetCore.Razor.Threading; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Formatting; using Microsoft.CodeAnalysis.Razor.Logging; @@ -35,6 +40,8 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting; public abstract class FormattingTestBase : RazorToolingIntegrationTestBase { + private static readonly AsyncLazy> s_standardTagHelpers = AsyncLazy.Create(GetStandardTagHelpersAsync); + private readonly HtmlFormattingService _htmlFormattingService; private readonly FormattingTestContext _context; @@ -82,6 +89,8 @@ private async Task RunFormattingTestInternalAsync(string input, string expected, ? null : source.GetLinePositionSpan(spans.Single()); + tagHelpers = tagHelpers.AddRange(await s_standardTagHelpers.GetValueAsync(DisposalToken)); + var path = "file:///path/to/Document." + fileKind; var uri = new Uri(path); var (codeDocument, documentSnapshot) = CreateCodeDocumentAndSnapshot(source, uri.AbsolutePath, tagHelpers, fileKind, allowDiagnostics, inGlobalNamespace); @@ -136,10 +145,12 @@ private protected async Task RunOnTypeFormattingTestAsync( TestFileMarkupParser.GetPosition(input, out input, out var positionAfterTrigger); + var tagHelpers = await s_standardTagHelpers.GetValueAsync(DisposalToken); + var razorSourceText = SourceText.From(input); var path = "file:///path/to/Document.razor"; var uri = new Uri(path); - var (codeDocument, documentSnapshot) = CreateCodeDocumentAndSnapshot(razorSourceText, uri.AbsolutePath, fileKind: fileKind, inGlobalNamespace: inGlobalNamespace); + var (codeDocument, documentSnapshot) = CreateCodeDocumentAndSnapshot(razorSourceText, uri.AbsolutePath, tagHelpers, fileKind: fileKind, inGlobalNamespace: inGlobalNamespace); var languageServerFeatureOptions = new TestLanguageServerFeatureOptions(useNewFormattingEngine: _context.UseNewFormattingEngine); @@ -266,25 +277,19 @@ protected static TextEdit Edit(int startLine, int startChar, int endLine, int en private static (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnapshot(SourceText text, string path, ImmutableArray tagHelpers = default, string? fileKind = null, bool allowDiagnostics = false, bool inGlobalNamespace = false) { fileKind ??= FileKinds.Component; - tagHelpers = tagHelpers.NullToEmpty(); - - if (fileKind == FileKinds.Component) - { - tagHelpers = tagHelpers.AddRange(RazorTestResources.BlazorServerAppTagHelpers); - } var sourceDocument = RazorSourceDocument.Create(text, RazorSourceDocumentProperties.Create( filePath: path, relativePath: inGlobalNamespace ? Path.GetFileName(path) : path)); const string DefaultImports = """ - @using BlazorApp1 - @using BlazorApp1.Pages - @using BlazorApp1.Shared @using Microsoft.AspNetCore.Components @using Microsoft.AspNetCore.Components.Authorization + @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web + + @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers """; var importPath = new Uri("file:///path/to/_Imports.razor").AbsolutePath; @@ -393,4 +398,53 @@ internal static IDocumentSnapshot CreateDocumentSnapshot( return snapshotMock.Object; } + + private static async Task> GetStandardTagHelpersAsync(CancellationToken cancellationToken) + { + var projectId = ProjectId.CreateNewId(); + var projectInfo = ProjectInfo + .Create( + projectId, + VersionStamp.Create(), + name: TestProjectData.SomeProject.FilePath, + assemblyName: TestProjectData.SomeProject.FilePath, + LanguageNames.CSharp, + TestProjectData.SomeProject.FilePath, + compilationOptions: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)) + .WithMetadataReferences(AspNet80.ReferenceInfos.All.Select(r => r.Reference)) + .WithDefaultNamespace(TestProjectData.SomeProject.RootNamespace); + + var workspace = new AdhocWorkspace(); + var project = workspace.CurrentSolution.AddProject(projectInfo).GetProject(projectId); + + var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + if (compilation is null) + { + return []; + } + + var configuration = new RazorConfiguration( + RazorLanguageVersion.Experimental, + "MVC-3.0", + Extensions: [], + CSharpLanguageVersion: CSharpParseOptions.Default.LanguageVersion, + UseConsolidatedMvcViews: true, + SuppressAddComponentParameter: false, + UseRoslynTokenizer: false, + PreprocessorSymbols: []); + + var fileSystem = RazorProjectFileSystem.Create(TestProjectData.SomeProject.FilePath); + + var engineFactory = ProjectEngineFactories.DefaultProvider.GetFactory(configuration); + + var engine = engineFactory.Create( + configuration, + fileSystem, + configure: null); + + var tagHelpers = await project.GetTagHelpersAsync(engine, NoOpTelemetryReporter.Instance, cancellationToken).ConfigureAwait(false); + Assert.NotEmpty(tagHelpers); + + return tagHelpers; + } } From 26bf271834fe1d409dc5f5e8cc9f588455f65c2d Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:36:55 +1100 Subject: [PATCH 08/14] Generate design time and runtime documents in language server formatting tests --- .../FormattingDiagnosticValidationPassTest.cs | 2 +- .../Formatting_NetFx/FormattingTestBase.cs | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) 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 98c5832726d..17593e9db8c 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 @@ -105,7 +105,7 @@ private static (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnaps var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, importSources: default, tagHelpers); var documentSnapshot = FormattingTestBase.CreateDocumentSnapshot( - path, fileKind, codeDocument, projectEngine, imports: [], importDocuments: [], tagHelpers, inGlobalNamespace: false); + path, fileKind, codeDocument, codeDocument, projectEngine, imports: [], importDocuments: [], tagHelpers, inGlobalNamespace: false, forceRuntimeCodeGeneration: false); return (codeDocument, documentSnapshot); } 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 601be213bfb..2f895b3d2d5 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 @@ -274,7 +274,7 @@ protected async Task RunCodeActionFormattingTestAsync( protected static TextEdit Edit(int startLine, int startChar, int endLine, int endChar, string newText) => VsLspFactory.CreateTextEdit(startLine, startChar, endLine, endChar, newText); - private static (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnapshot(SourceText text, string path, ImmutableArray tagHelpers = default, string? fileKind = null, bool allowDiagnostics = false, bool inGlobalNamespace = false) + private (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnapshot(SourceText text, string path, ImmutableArray tagHelpers, string? fileKind = null, bool allowDiagnostics = false, bool inGlobalNamespace = false) { fileKind ??= FileKinds.Component; @@ -326,7 +326,10 @@ @using Microsoft.AspNetCore.Components.Web RazorExtensions.Register(builder); }); - var codeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, [importSource], tagHelpers); + var designTimeCodeDocument = projectEngine.ProcessDesignTime(sourceDocument, fileKind, [importSource], tagHelpers); + var codeDocument = _context.ForceRuntimeCodeGeneration + ? projectEngine.Process(sourceDocument, fileKind, [importSource], tagHelpers) + : designTimeCodeDocument; if (!allowDiagnostics) { @@ -334,7 +337,7 @@ @using Microsoft.AspNetCore.Components.Web } var documentSnapshot = CreateDocumentSnapshot( - path, fileKind, codeDocument, projectEngine, [importSnapshotMock.Object], [importSource], tagHelpers, inGlobalNamespace); + path, fileKind, codeDocument, designTimeCodeDocument, projectEngine, [importSnapshotMock.Object], [importSource], tagHelpers, inGlobalNamespace, _context.ForceRuntimeCodeGeneration); return (codeDocument, documentSnapshot); } @@ -343,11 +346,13 @@ internal static IDocumentSnapshot CreateDocumentSnapshot( string path, string fileKind, RazorCodeDocument codeDocument, + RazorCodeDocument designTimeCodeDocument, RazorProjectEngine projectEngine, ImmutableArray imports, ImmutableArray importDocuments, ImmutableArray tagHelpers, - bool inGlobalNamespace) + bool inGlobalNamespace, + bool forceRuntimeCodeGeneration) { var snapshotMock = new StrictMock(); @@ -383,18 +388,19 @@ internal static IDocumentSnapshot CreateDocumentSnapshot( filePath: path, relativePath: inGlobalNamespace ? Path.GetFileName(path) : path)); - var codeDocument = projectEngine.ProcessDesignTime(source, fileKind, importDocuments, tagHelpers); + var designTimeCodeDocument = projectEngine.ProcessDesignTime(source, fileKind, importDocuments, tagHelpers); + var codeDocument = forceRuntimeCodeGeneration + ? projectEngine.Process(source, fileKind, importDocuments, tagHelpers) + : designTimeCodeDocument; return CreateDocumentSnapshot( - path, fileKind, codeDocument, projectEngine, imports, importDocuments, tagHelpers, inGlobalNamespace); + path, fileKind, codeDocument, designTimeCodeDocument, projectEngine, imports, importDocuments, tagHelpers, inGlobalNamespace, forceRuntimeCodeGeneration); }); -#if !FORMAT_FUSE var generatorMock = snapshotMock.As(); generatorMock .Setup(x => x.GenerateDesignTimeOutputAsync(It.IsAny())) - .ReturnsAsync(codeDocument); -#endif + .ReturnsAsync(designTimeCodeDocument); return snapshotMock.Object; } From 4d1e2e0fc75047a81c81f947568fb81aba5e015b Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:38:56 +1100 Subject: [PATCH 09/14] Remove FORMAT_FILE Cohosting is always FUSE, so never has design time documents. Language Server can have both, and the formatting engine decides based on interface implementation, not preproccesor directive. --- .../InlineCompletionEndPoint.cs | 4 +- .../Formatting/FormattingContext.cs | 32 +++++----- .../Formatting/RazorFormattingService.cs | 36 +++++------- .../ProjectSystem/DocumentSnapshot.cs | 7 +-- .../ProjectSystem/IDesignTimeCodeGenerator.cs | 2 - .../RemoteInlineCompletionService.cs | 2 +- .../ProjectSystem/RemoteDocumentSnapshot.cs | 15 ----- .../ProjectSystem/RemoteProjectSnapshot.cs | 58 ------------------- .../FormattingContentValidationPassTest.cs | 3 +- .../FormattingDiagnosticValidationPassTest.cs | 3 +- 10 files changed, 38 insertions(+), 124 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/InlineCompletion/InlineCompletionEndPoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/InlineCompletion/InlineCompletionEndPoint.cs index ea2ceb05bed..ddec25215c4 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/InlineCompletion/InlineCompletionEndPoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/InlineCompletion/InlineCompletionEndPoint.cs @@ -113,7 +113,9 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalInlineCompleti var formattingContext = FormattingContext.Create( documentContext.Snapshot, codeDocument, - options); + options, + // I don't think this makes a difference for inline completions, but it's better to be safe. + useNewFormattingEngine: false); if (!SnippetFormatter.TryGetSnippetWithAdjustedIndentation(formattingContext, item.Text, hostDocumentIndex, out var newSnippetText)) { continue; diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs index d8c841e54f5..14cd4e20f00 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs @@ -13,19 +13,17 @@ using Microsoft.AspNetCore.Razor.Language.Syntax; using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; -#if !FORMAT_FUSE -using Microsoft.CodeAnalysis.Razor.ProjectSystem; -#endif - namespace Microsoft.CodeAnalysis.Razor.Formatting; internal sealed class FormattingContext { private IReadOnlyList? _formattingSpans; private IReadOnlyDictionary? _indentations; + private readonly bool _useNewFormattingEngine; private FormattingContext( IDocumentSnapshot originalSnapshot, @@ -33,7 +31,8 @@ private FormattingContext( RazorFormattingOptions options, bool automaticallyAddUsings, int hostDocumentIndex, - char triggerCharacter) + char triggerCharacter, + bool useNewFormattingEngine) { OriginalSnapshot = originalSnapshot; CodeDocument = codeDocument; @@ -41,6 +40,7 @@ private FormattingContext( AutomaticallyAddUsings = automaticallyAddUsings; HostDocumentIndex = hostDocumentIndex; TriggerCharacter = triggerCharacter; + _useNewFormattingEngine = useNewFormattingEngine; } public static bool SkipValidateComponents { get; set; } @@ -229,13 +229,9 @@ public async Task WithTextAsync(SourceText changedText, Cance { var changedSnapshot = OriginalSnapshot.WithText(changedText); -#if !FORMAT_FUSE - // Formatting always uses design time document - var generator = (IDesignTimeCodeGenerator)changedSnapshot; - var codeDocument = await generator.GenerateDesignTimeOutputAsync(cancellationToken).ConfigureAwait(false); -#else - var codeDocument = await changedSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); -#endif + var codeDocument = !_useNewFormattingEngine && changedSnapshot is IDesignTimeCodeGenerator generator + ? await generator.GenerateDesignTimeOutputAsync(cancellationToken).ConfigureAwait(false) + : await changedSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); DEBUG_ValidateComponents(CodeDocument, codeDocument); @@ -245,7 +241,8 @@ public async Task WithTextAsync(SourceText changedText, Cance Options, AutomaticallyAddUsings, HostDocumentIndex, - TriggerCharacter); + TriggerCharacter, + _useNewFormattingEngine); return newContext; } @@ -282,13 +279,15 @@ public static FormattingContext CreateForOnTypeFormatting( options, automaticallyAddUsings, hostDocumentIndex, - triggerCharacter); + triggerCharacter, + useNewFormattingEngine: false); } public static FormattingContext Create( IDocumentSnapshot originalSnapshot, RazorCodeDocument codeDocument, - RazorFormattingOptions options) + RazorFormattingOptions options, + bool useNewFormattingEngine) { return new FormattingContext( originalSnapshot, @@ -296,6 +295,7 @@ public static FormattingContext Create( options, automaticallyAddUsings: false, hostDocumentIndex: 0, - triggerCharacter: '\0'); + triggerCharacter: '\0', + useNewFormattingEngine: useNewFormattingEngine); } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs index 1d12baeb1a8..d9ddbc564ca 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs @@ -34,6 +34,7 @@ internal class RazorFormattingService : IRazorFormattingService private readonly ImmutableArray _validationPasses; private readonly CSharpOnTypeFormattingPass _csharpOnTypeFormattingPass; private readonly HtmlOnTypeFormattingPass _htmlOnTypeFormattingPass; + private readonly LanguageServerFeatureOptions _languageServerFeatureOptions; public RazorFormattingService( IDocumentMappingService documentMappingService, @@ -49,7 +50,8 @@ public RazorFormattingService( new FormattingContentValidationPass(loggerFactory) ]; - _documentFormattingPasses = languageServerFeatureOptions.UseNewFormattingEngine + _languageServerFeatureOptions = languageServerFeatureOptions; + _documentFormattingPasses = _languageServerFeatureOptions.UseNewFormattingEngine ? [ new New.HtmlFormattingPass(loggerFactory), new RazorFormattingPass(languageServerFeatureOptions, loggerFactory), @@ -71,13 +73,9 @@ public async Task> GetDocumentFormattingChangesAsync( RazorFormattingOptions options, CancellationToken cancellationToken) { -#if !FORMAT_FUSE - // Formatting always uses design time document - var generator = (IDesignTimeCodeGenerator)documentContext.Snapshot; - var codeDocument = await generator.GenerateDesignTimeOutputAsync(cancellationToken).ConfigureAwait(false); -#else - var codeDocument = await documentContext.Snapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); -#endif + var codeDocument = !_languageServerFeatureOptions.UseNewFormattingEngine && documentContext.Snapshot is IDesignTimeCodeGenerator generator + ? await generator.GenerateDesignTimeOutputAsync(cancellationToken).ConfigureAwait(false) + : await documentContext.Snapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); // Range formatting happens on every paste, and if there are Razor diagnostics in the file // that can make some very bad results. eg, given: @@ -108,7 +106,8 @@ public async Task> GetDocumentFormattingChangesAsync( var context = FormattingContext.Create( documentSnapshot, codeDocument, - options); + options, + _languageServerFeatureOptions.UseNewFormattingEngine); var originalText = context.SourceText; var result = htmlChanges; @@ -130,13 +129,9 @@ public async Task> GetCSharpOnTypeFormattingChangesAs { var documentSnapshot = documentContext.Snapshot; -#if !FORMAT_FUSE - // Formatting always uses design time document - var generator = (IDesignTimeCodeGenerator)documentSnapshot; - var codeDocument = await generator.GenerateDesignTimeOutputAsync(cancellationToken).ConfigureAwait(false); -#else - var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); -#endif + var codeDocument = documentContext.Snapshot is IDesignTimeCodeGenerator generator + ? await generator.GenerateDesignTimeOutputAsync(cancellationToken).ConfigureAwait(false) + : await documentContext.Snapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); return await ApplyFormattedChangesAsync( documentSnapshot, @@ -155,13 +150,8 @@ public async Task> GetHtmlOnTypeFormattingChangesAsyn { var documentSnapshot = documentContext.Snapshot; -#if !FORMAT_FUSE - // Formatting always uses design time document - var generator = (IDesignTimeCodeGenerator)documentSnapshot; - var codeDocument = await generator.GenerateDesignTimeOutputAsync(cancellationToken).ConfigureAwait(false); -#else - var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); -#endif + // Html formatting doesn't use the C# design time document + var codeDocument = await documentContext.Snapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); return await ApplyFormattedChangesAsync( documentSnapshot, diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs index d2d3b292518..d89efaeb91d 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs @@ -11,10 +11,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; -internal sealed class DocumentSnapshot(ProjectSnapshot project, DocumentState state) : IDocumentSnapshot, ILegacyDocumentSnapshot -#if !FORMAT_FUSE - , IDesignTimeCodeGenerator -#endif +internal sealed class DocumentSnapshot(ProjectSnapshot project, DocumentState state) : IDocumentSnapshot, ILegacyDocumentSnapshot, IDesignTimeCodeGenerator { public ProjectSnapshot Project { get; } = project; @@ -65,10 +62,8 @@ async Task GetCSharpSyntaxTreeCoreAsync(CancellationToken cancellati } } -#if !FORMAT_FUSE public Task GenerateDesignTimeOutputAsync(CancellationToken cancellationToken) => CompilationHelpers.GenerateDesignTimeCodeDocumentAsync(this, Project.ProjectEngine, cancellationToken); -#endif #region ILegacyDocumentSnapshot support diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDesignTimeCodeGenerator.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDesignTimeCodeGenerator.cs index e7e36b53aba..55937d186db 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDesignTimeCodeGenerator.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDesignTimeCodeGenerator.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT license. See License.txt in the project root for license information. -#if !FORMAT_FUSE using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.Language; @@ -12,4 +11,3 @@ internal interface IDesignTimeCodeGenerator { Task GenerateDesignTimeOutputAsync(CancellationToken cancellationToken); } -#endif diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/InlineCompletion/RemoteInlineCompletionService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/InlineCompletion/RemoteInlineCompletionService.cs index ae79ecc3a99..0a6d69c1e3d 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/InlineCompletion/RemoteInlineCompletionService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/InlineCompletion/RemoteInlineCompletionService.cs @@ -70,7 +70,7 @@ protected override IRemoteInlineCompletionService CreateService(in ServiceArgs a var hostDocumentIndex = codeDocument.Source.Text.GetRequiredAbsoluteIndex(razorRange.End); - var formattingContext = FormattingContext.Create(context.Snapshot, codeDocument, options); + var formattingContext = FormattingContext.Create(context.Snapshot, codeDocument, options, useNewFormattingEngine: false); if (!SnippetFormatter.TryGetSnippetWithAdjustedIndentation(formattingContext, text, hostDocumentIndex, out var newSnippetText)) { return null; diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteDocumentSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteDocumentSnapshot.cs index 84009a57db4..d910cd9de43 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteDocumentSnapshot.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteDocumentSnapshot.cs @@ -8,15 +8,11 @@ using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.ProjectSystem; -using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem; internal sealed class RemoteDocumentSnapshot : IDocumentSnapshot -#if !FORMAT_FUSE - , IDesignTimeCodeGenerator -#endif { public TextDocument TextDocument { get; } public RemoteProjectSnapshot ProjectSnapshot { get; } @@ -80,17 +76,6 @@ public async ValueTask GetGeneratedOutputAsync(CancellationTo return InterlockedOperations.Initialize(ref _codeDocument, document); } -#if !FORMAT_FUSE - public async Task GenerateDesignTimeOutputAsync(CancellationToken cancellationToken) - { - var projectEngine = await ProjectSnapshot.GetProjectEngineAsync(cancellationToken).ConfigureAwait(false); - - return await CompilationHelpers - .GenerateDesignTimeCodeDocumentAsync(this, projectEngine, cancellationToken) - .ConfigureAwait(false); - } -#endif - public IDocumentSnapshot WithText(SourceText text) { var id = TextDocument.Id; diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteProjectSnapshot.cs index 7480679fe20..1c6175485ee 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteProjectSnapshot.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteProjectSnapshot.cs @@ -5,15 +5,12 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Language; -using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.AspNetCore.Razor.ProjectSystem; -using Microsoft.AspNetCore.Razor.Threading; using Microsoft.AspNetCore.Razor.Utilities; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -30,10 +27,6 @@ internal sealed class RemoteProjectSnapshot : IProjectSnapshot public ProjectKey Key { get; } private readonly Project _project; -#if !FORMAT_FUSE - private readonly AsyncLazy _lazyConfiguration; - private readonly AsyncLazy _lazyProjectEngine; -#endif private readonly Dictionary _documentMap = []; public RemoteProjectSnapshot(Project project, RemoteSolutionSnapshot solutionSnapshot) @@ -46,11 +39,6 @@ public RemoteProjectSnapshot(Project project, RemoteSolutionSnapshot solutionSna _project = project; SolutionSnapshot = solutionSnapshot; Key = _project.ToProjectKey(); - -#if !FORMAT_FUSE - _lazyConfiguration = AsyncLazy.Create(ComputeConfigurationAsync); - _lazyProjectEngine = AsyncLazy.Create(ComputeProjectEngineAsync); -#endif } public IEnumerable DocumentFilePaths @@ -230,50 +218,4 @@ public bool TryGetDocument(string filePath, [NotNullWhen(true)] out IDocumentSna return generatorResult; } - -#if !FORMAT_FUSE - /// - /// NOTE: This will be removed when the source generator is used directly. - /// - public ValueTask GetProjectEngineAsync(CancellationToken cancellationToken) - { - if (_lazyProjectEngine.TryGetValue(out var result)) - { - return new(result); - } - - return new(_lazyProjectEngine.GetValueAsync(cancellationToken)); - } - - private async Task ComputeConfigurationAsync(CancellationToken cancellationToken) - { - var compilation = await _project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - - return RazorProjectInfoFactory.ComputeRazorConfigurationOptions(_project, compilation, out _); - } - - private async Task ComputeProjectEngineAsync(CancellationToken cancellationToken) - { - var configuration = await _lazyConfiguration.GetValueAsync(cancellationToken).ConfigureAwait(false); - - var useRoslynTokenizer = configuration.UseRoslynTokenizer; - var parseOptions = new CSharpParseOptions(languageVersion: CSharpLanguageVersion, preprocessorSymbols: configuration.PreprocessorSymbols); - - return ProjectEngineFactories.DefaultProvider.Create( - configuration, - rootDirectoryPath: Path.GetDirectoryName(FilePath).AssumeNotNull(), - configure: builder => - { - builder.SetRootNamespace(RootNamespace); - builder.SetCSharpLanguageVersion(CSharpLanguageVersion); - builder.SetSupportLocalizedComponentNames(); - - builder.ConfigureParserOptions(builder => - { - builder.UseRoslynTokenizer = useRoslynTokenizer; - builder.CSharpParseOptions = parseOptions; - }); - }); - } -#endif } 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 8e91a5cf850..e443aede77d 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 @@ -86,7 +86,8 @@ private static FormattingContext CreateFormattingContext(TestCode input, int tab var context = FormattingContext.Create( documentSnapshot, codeDocument, - options); + options, + useNewFormattingEngine: false); return context; } 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 17593e9db8c..f5acbae0706 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 @@ -84,7 +84,8 @@ private static FormattingContext CreateFormattingContext(TestCode input, int tab var context = FormattingContext.Create( documentSnapshot, codeDocument, - options); + options, + useNewFormattingEngine: false); return context; } From 600101b70f9a7aa9ebe184bb57d08f9ececcca1c Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:39:49 +1100 Subject: [PATCH 10/14] Fix on type formatting test Previous behaviour seemed like the old formatting engine being over-zealous. This change makes both engines behave the same, which I prefer to skipping --- .../Formatting_NetFx/OnTypeFormattingTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/OnTypeFormattingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/OnTypeFormattingTest.cs index 804c37afba7..140fdc25b32 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/OnTypeFormattingTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/OnTypeFormattingTest.cs @@ -976,7 +976,7 @@ await RunOnTypeFormattingTestAsync( input: """
@{ - if(true) { } + if(true) { } }
From c35de2256b1534b8c30c98800ee929378bbf04d9 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:40:52 +1100 Subject: [PATCH 11/14] Update component used in tests Counter and SurveyPrompt were in the json, but aren't part of the framework --- .../DocumentFormattingTest.cs | 106 +++++++++--------- .../Formatting_NetFx/HtmlFormattingTest.cs | 8 +- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs index 5c0ba086188..0caed2e37e3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs @@ -1358,7 +1358,7 @@ await RunFormattingTestAsync( Welcome to your new app. - +
@@ -1411,7 +1411,7 @@ void Method() { } Welcome to your new app. - +
@@ -1820,7 +1820,7 @@ await RunFormattingTestAsync( public async Task FormatRenderFragmentInCSharpCodeBlock1() { // Sadly the first thing the HTML formatter does with this input - // is put a newline after the @, which means won't be + // is put a newline after the @, which means won't be // seen as a component any more, so we have to turn off our validation, // or the test fails before we have a chance to fix the formatting. FormattingContext.SkipValidateComponents = true; @@ -1832,9 +1832,9 @@ await RunFormattingTestAsync( public void DoStuff(RenderFragment renderFragment) { DoThings(); - renderFragment(@); + renderFragment(@); DoThings(); - renderFragment(@); + renderFragment(@); @* comment *@
@@ -1849,9 +1849,9 @@ public void DoStuff(RenderFragment renderFragment) public void DoStuff(RenderFragment renderFragment) { DoThings(); - renderFragment(@); + renderFragment(@); DoThings(); - renderFragment(@); + renderFragment(@); @* comment *@
@@ -1868,7 +1868,7 @@ public void DoStuff(RenderFragment renderFragment) public async Task FormatRenderFragmentInCSharpCodeBlock2() { // Sadly the first thing the HTML formatter does with this input - // is put a newline after the @, which means won't be + // is put a newline after the @, which means won't be // seen as a component any more, so we have to turn off our validation, // or the test fails before we have a chance to fix the formatting. FormattingContext.SkipValidateComponents = true; @@ -1877,7 +1877,7 @@ await RunFormattingTestAsync( input: """
@{ - renderFragment(@); + renderFragment(@); @* comment *@
@@ -1889,7 +1889,7 @@ await RunFormattingTestAsync( expected: """
@{ - renderFragment(@); + renderFragment(@); @* comment *@
@@ -1906,7 +1906,7 @@ await RunFormattingTestAsync( public async Task FormatRenderFragmentInCSharpCodeBlock3() { // Sadly the first thing the HTML formatter does with this input - // is put a newline after the @, which means won't be + // is put a newline after the @, which means won't be // seen as a component any more, so we have to turn off our validation, // or the test fails before we have a chance to fix the formatting. FormattingContext.SkipValidateComponents = true; @@ -1915,7 +1915,7 @@ await RunFormattingTestAsync( input: """
@{ - renderFragment (@); + renderFragment (@); @* comment *@
@@ -1927,7 +1927,7 @@ await RunFormattingTestAsync( expected: """
@{ - renderFragment(@); + renderFragment(@); @* comment *@
@@ -2050,12 +2050,12 @@ await RunFormattingTestAsync( { - + @if (VarBool) {
- - + +
}
@@ -2077,12 +2077,12 @@ await RunFormattingTestAsync( { - + @if (VarBool) {
- - + +
}
@@ -2111,12 +2111,12 @@ await RunFormattingTestAsync( @if (Object1!= null) { - + @if (VarBool) {
- - + +
}
@@ -2136,12 +2136,12 @@ await RunFormattingTestAsync( @if (Object1 != null) { - + @if (VarBool) {
- - + +
}
@@ -2170,12 +2170,12 @@ await RunFormattingTestAsync( { @if (VarBool) { - + @if (VarBool) {
- - + +
} } @@ -2196,12 +2196,12 @@ await RunFormattingTestAsync( { @if (VarBool) { - + @if (VarBool) {
- - + +
} } @@ -2227,12 +2227,12 @@ await RunFormattingTestAsync( @using Microsoft.AspNetCore.Components.Forms; - + @if (VarBool) {
- - + +
}
@@ -2249,12 +2249,12 @@ await RunFormattingTestAsync( @using Microsoft.AspNetCore.Components.Forms; - + @if (VarBool) {
- - + +
}
@@ -2281,12 +2281,12 @@ await RunFormattingTestAsync( @if (Object1!= null) { - + @if (VarBool) {
- - + +
}
@@ -2306,12 +2306,12 @@ await RunFormattingTestAsync( @if (Object1 != null) { - + @if (VarBool) {
- - + +
}
@@ -2340,12 +2340,12 @@ await RunFormattingTestAsync( {
- + @if (VarBool) {
- - + +
}
@@ -2367,12 +2367,12 @@ await RunFormattingTestAsync( {
- + @if (VarBool) {
- - + +
}
@@ -4463,12 +4463,12 @@ await RunFormattingTestAsync( protected override async Task OnInitializedAsync() { - + @{ var t = DateTime.Now; t.ToString(); } - +
forecasts = await ForecastService.GetForecastAsync(DateTime.Now); } } @@ -4479,12 +4479,12 @@ protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync() { - + @{ var t = DateTime.Now; t.ToString(); } - +
forecasts = await ForecastService.GetForecastAsync(DateTime.Now); } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/HtmlFormattingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/HtmlFormattingTest.cs index ec274101425..2350d27926b 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/HtmlFormattingTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/HtmlFormattingTest.cs @@ -24,11 +24,11 @@ public async Task FormatsComponentTags() var tagHelpers = GetComponents(); await RunFormattingTestAsync( input: """ - + @if(true){

@DateTime.Now

} -
+
@foreach (var row in rows){ @@ -39,12 +39,12 @@ await RunFormattingTestAsync( """, expected: """ - + @if (true) {

@DateTime.Now

} -
+
@foreach (var row in rows) From b71a233787a69ea26bcef7fe513bc1149b08375e Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:41:20 +1100 Subject: [PATCH 12/14] Unskip partial component test Now that we're using the real framework, this test is valid in the language server --- .../Formatting_NetFx/DocumentFormattingTest.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs index 0caed2e37e3..12be0c452eb 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs @@ -5907,11 +5907,7 @@ @@media only screen and (max-width: 600px) { """); } -#if COHOSTING [FormattingTestFact(SkipOldFormattingEngine = true)] -#else - [FormattingTestFact(Skip = "Language server test infra doesn't have a partial tag helper")] -#endif public async Task PartialTagHelper() { await RunFormattingTestAsync( From 08ebaf15fd93db6205332de03c600e42f2c0b095 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 6 Mar 2025 14:42:17 +1100 Subject: [PATCH 13/14] Remove code actions tests These tests had hard coded positions in them, for locations in the generated C# file. This is very fragile, and broke with other changes. Two of these scenarios are covered by other unit tests, and one by an integration test. --- .../CodeActionFormattingTest.cs | 110 ------------------ .../Formatting_NetFx/FormattingTestBase.cs | 55 --------- 2 files changed, 165 deletions(-) delete mode 100644 src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/CodeActionFormattingTest.cs diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/CodeActionFormattingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/CodeActionFormattingTest.cs deleted file mode 100644 index aeedff87d0f..00000000000 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/CodeActionFormattingTest.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the MIT license. See License.txt in the project root for license information. - -using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Test.Common; -using Microsoft.CodeAnalysis.Razor.Formatting; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Razor.LanguageServer.Formatting; - -[Collection(HtmlFormattingCollection.Name)] -public class CodeActionFormattingTest(FormattingTestContext context, HtmlFormattingFixture fixture, ITestOutputHelper testOutput) - : FormattingTestBase(context, fixture.Service, testOutput), IClassFixture -{ - [Fact] - public async Task AddDebuggerDisplay() - { - await RunCodeActionFormattingTestAsync( -input: @" -@functions { - class Goo$$ - { - - } -} -", -codeActionEdits: new[] -{ -Edit(7, 6, 7, 6, "System.Diagnostics;\r\nusing "), -Edit(57, 0, 57, 8, ""), -Edit(59, 34, 60, 7, "\r\n\r\n [DebuggerDisplay($\"{{{nameof(GetDebuggerDisplay)}(),nq}}\")]"), -Edit(61, 0, 61, 4, " "), -Edit(62, 5, 62, 5, "\r\n private string GetDebuggerDisplay()\r\n {"), -Edit(63, 0, 63, 0, " return ToString();\r\n }\r\n"), -Edit(63, 8, 64, 4, "") -}, -expected: @"@using System.Diagnostics - -@functions { - [DebuggerDisplay($""{{{nameof(GetDebuggerDisplay)}(),nq}}"")] - class Goo - { - private string GetDebuggerDisplay() - { - return ToString(); - } - } -} -"); - } - - [Fact] - public async Task GenerateConstructor() - { - await RunCodeActionFormattingTestAsync( -input: @" -@functions { - class Goo$$ - { - - } -} -", -codeActionEdits: new[] -{ -Edit(57, 0, 57, 8, ""), -Edit(59, 33, 59, 33, "\r\n\r\n class Goo"), -Edit(60, 0, 60, 12, " {"), -Edit(61, 0, 61, 9, " public"), -Edit(61, 13, 61, 13, "()"), -Edit(62, 0, 62, 4, " "), -Edit(63, 0, 63, 4, " }"), -Edit(64, 0, 64, 4, " "), -}, -expected: @" -@functions { - class Goo - { - public Goo() - { - } - } -} -"); - } - - [Fact] - public async Task OverrideCompletion() - { - await RunCodeActionFormattingTestAsync( -input: @" -@functions { - override $$ -} -", -codeActionEdits: new[] -{ -Edit(55, 0, 62, 0, " {\r\n }\r\n#pragma warning restore 1998\r\n#nullable restore\r\n#line 2 \"e:/Scratch/BlazorApp13/BlazorApp13/Client/Pages/Test.razor\"\r\n\r\n protected override void OnAfterRender(bool firstRender)\r\n {\r\n base.OnAfterRender(firstRender);/*$0*/\r\n }\r\n"), -}, -expected: @" -@functions { - protected override void OnAfterRender(bool firstRender) - { - base.OnAfterRender(firstRender);/*$0*/ - } -} -"); - } -} 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 2f895b3d2d5..81e2ab4b9e0 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 @@ -219,61 +219,6 @@ private protected async Task RunOnTypeFormattingTestAsync( return (input, expected); } - protected async Task RunCodeActionFormattingTestAsync( - string input, - TextEdit[] codeActionEdits, - string expected, - int tabSize = 4, - bool insertSpaces = true, - string? fileKind = null, - bool inGlobalNamespace = false) - { - // Arrange - fileKind ??= FileKinds.Component; - - TestFileMarkupParser.GetPosition(input, out input, out var positionAfterTrigger); - - var razorSourceText = SourceText.From(input); - var path = "file:///path/to/Document.razor"; - var uri = new Uri(path); - var (codeDocument, documentSnapshot) = CreateCodeDocumentAndSnapshot(razorSourceText, uri.AbsolutePath, fileKind: fileKind, inGlobalNamespace: inGlobalNamespace); - - var filePathService = new LSPFilePathService(TestLanguageServerFeatureOptions.Instance); - var mappingService = new LspDocumentMappingService(filePathService, new TestDocumentContextFactory(), LoggerFactory); - var languageKind = codeDocument.GetLanguageKind(positionAfterTrigger, rightAssociative: false); - if (languageKind == RazorLanguageKind.Html) - { - throw new NotImplementedException("Code action formatting is not yet supported for HTML in Razor."); - } - - if (!mappingService.TryMapToGeneratedDocumentPosition(codeDocument.GetCSharpDocument(), positionAfterTrigger, out _, out var _)) - { - throw new InvalidOperationException("Could not map from Razor document to generated document"); - } - - var formattingService = await TestRazorFormattingService.CreateWithFullSupportAsync(LoggerFactory, codeDocument); - var options = new RazorFormattingOptions() - { - TabSize = tabSize, - InsertSpaces = insertSpaces, - }; - var documentContext = new DocumentContext(uri, documentSnapshot, projectContext: null); - - // Act - var csharpSourceText = codeDocument.GetCSharpSourceText(); - var changes = codeActionEdits.SelectAsArray(csharpSourceText.GetTextChange); - var edit = await formattingService.TryGetCSharpCodeActionEditAsync(documentContext, changes, options, DisposalToken); - - // Assert - var edited = razorSourceText.WithChanges(edit.Value); - var actual = edited.ToString(); - - AssertEx.EqualOrDiff(expected, actual); - } - - protected static TextEdit Edit(int startLine, int startChar, int endLine, int endChar, string newText) - => VsLspFactory.CreateTextEdit(startLine, startChar, endLine, endChar, newText); - private (RazorCodeDocument, IDocumentSnapshot) CreateCodeDocumentAndSnapshot(SourceText text, string path, ImmutableArray tagHelpers, string? fileKind = null, bool allowDiagnostics = false, bool inGlobalNamespace = false) { fileKind ??= FileKinds.Component; From b229967ec6eedd91f0526320abff2b530c7df234 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 7 Mar 2025 09:35:36 +1100 Subject: [PATCH 14/14] Remove unused compilation and comment --- Directory.Build.props | 3 --- .../Formatting_NetFx/FormattingTestBase.cs | 6 ------ 2 files changed, 9 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index e552eb5d0eb..d404f3bea7b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -47,9 +47,6 @@ true net472 - - -