diff --git a/Razor.Slim.slnf b/Razor.Slim.slnf index c261ebaa86a..1dc8a06ff9a 100644 --- a/Razor.Slim.slnf +++ b/Razor.Slim.slnf @@ -33,6 +33,7 @@ "src\\Razor\\test\\Microsoft.CodeAnalysis.Remote.Razor.Test\\Microsoft.CodeAnalysis.Remote.Razor.Test.csproj", "src\\Razor\\test\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.csproj", "src\\Razor\\test\\Microsoft.VisualStudio.LanguageServices.Razor.Test\\Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj", + "src\\Razor\\test\\Microsoft.VisualStudioCode.RazorExtension.Test\\Microsoft.VisualStudioCode.RazorExtension.Test.csproj", "src\\Shared\\Microsoft.AspNetCore.Razor.Test.Common\\Microsoft.AspNetCore.Razor.Test.Common.csproj", "src\\Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared.Test\\Microsoft.AspNetCore.Razor.Utilities.Shared.Test.csproj", "src\\Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared.csproj", diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs index 456e2496f12..dab4114c904 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs @@ -35,13 +35,12 @@ public abstract class CohostTestBase(ITestOutputHelper testOutputHelper) : Tooli private TestIncompatibleProjectService _incompatibleProjectService = null!; private RemoteClientInitializationOptions _clientInitializationOptions; private RemoteClientLSPInitializationOptions _clientLSPInitializationOptions; - private IFilePathService? _filePathService; private protected abstract IRemoteServiceInvoker RemoteServiceInvoker { get; } private protected abstract IClientSettingsManager ClientSettingsManager { get; } + private protected abstract IFilePathService FilePathService { get; } private protected TestIncompatibleProjectService IncompatibleProjectService => _incompatibleProjectService.AssumeNotNull(); - private protected IFilePathService FilePathService => _filePathService.AssumeNotNull(); private protected RemoteLanguageServerFeatureOptions FeatureOptions => OOPExportProvider.GetExportedValue(); private protected RemoteClientCapabilitiesService ClientCapabilitiesService => OOPExportProvider.GetExportedValue(); private protected RemoteSemanticTokensLegendService SemanticTokensLegendService => OOPExportProvider.GetExportedValue(); @@ -92,8 +91,6 @@ protected override async Task InitializeAsync() _clientLSPInitializationOptions = GetRemoteClientLSPInitializationOptions(); UpdateClientLSPInitializationOptions(c => c); - _filePathService = new RemoteFilePathService(FeatureOptions); - // Force initialization and creation of the remote workspace. It will be filled in later. await RemoteWorkspaceProvider.TestAccessor.InitializeRemoteExportProviderBuilderAsync(Path.GetTempPath(), DisposalToken); _ = RemoteWorkspaceProvider.Instance.GetWorkspace(); 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 7748670fc34..e378e1687b2 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 @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Razor.Workspaces.Settings; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.Razor.Settings; @@ -22,10 +23,12 @@ public abstract class CohostEndpointTestBase(ITestOutputHelper testOutputHelper) { private TestRemoteServiceInvoker? _remoteServiceInvoker; private IClientSettingsManager? _clientSettingsManager; + private IFilePathService? _filePathService; private protected override IRemoteServiceInvoker RemoteServiceInvoker => _remoteServiceInvoker.AssumeNotNull(); private protected TestRemoteServiceInvoker TestRemoteServiceInvoker => _remoteServiceInvoker.AssumeNotNull(); private protected override IClientSettingsManager ClientSettingsManager => _clientSettingsManager.AssumeNotNull(); + private protected override IFilePathService FilePathService => _filePathService.AssumeNotNull(); /// /// The export provider for Roslyn "devenv" services, if tests opt-in to using them @@ -40,6 +43,8 @@ protected override async Task InitializeAsync() AddDisposable(_remoteServiceInvoker); _clientSettingsManager = new ClientSettingsManager([], null, null); + + _filePathService = new VisualStudioFilePathService(FeatureOptions); } private protected override RemoteClientLSPInitializationOptions GetRemoteClientLSPInitializationOptions() diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFindAllReferencesEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostFindAllReferencesEndpointTest.cs similarity index 83% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFindAllReferencesEndpointTest.cs rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostFindAllReferencesEndpointTest.cs index d476f7a2482..2bb3d8b5954 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFindAllReferencesEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostFindAllReferencesEndpointTest.cs @@ -17,9 +17,8 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; public class CohostFindAllReferencesEndpointTest(ITestOutputHelper testOutputHelper) : CohostEndpointTestBase(testOutputHelper) { - [Theory] - [CombinatorialData] - public Task FindCSharpMember(bool supportsVSExtensions) + [Fact] + public Task FindCSharpMember() => VerifyFindAllReferencesAsync(""" @{ string M() @@ -33,12 +32,10 @@ string M() @code { private const string [|$$MyName|] = "David"; } - """, - supportsVSExtensions); + """); - [Theory] - [CombinatorialData] - public async Task ComponentAttribute(bool supportsVSExtensions) + [Fact] + public async Task ComponentAttribute() { TestCode input = """ @@ -56,13 +53,12 @@ @namespace SomeProject } """; - await VerifyFindAllReferencesAsync(input, supportsVSExtensions, + await VerifyFindAllReferencesAsync(input, (FilePath("SurveyPrompt.razor"), surveyPrompt)); } - [Theory] - [CombinatorialData] - public async Task OtherCSharpFile(bool supportsVSExtensions) + [Fact] + public async Task OtherCSharpFile() { TestCode input = """ @code @@ -86,18 +82,12 @@ public class OtherClass } """; - await VerifyFindAllReferencesAsync(input, supportsVSExtensions, + await VerifyFindAllReferencesAsync(input, (FilePath("OtherClass.cs"), otherClass)); } - private async Task VerifyFindAllReferencesAsync(TestCode input, bool supportsVSExtensions, params (string fileName, TestCode testCode)[]? additionalFiles) + private async Task VerifyFindAllReferencesAsync(TestCode input, params (string fileName, TestCode testCode)[] additionalFiles) { - UpdateClientLSPInitializationOptions(c => - { - c.ClientCapabilities.SupportsVisualStudioExtensions = supportsVSExtensions; - return c; - }); - var document = CreateProjectAndRazorDocument(input.Text, additionalFiles: [.. additionalFiles.Select(f => (f.fileName, f.testCode.Text))]); var inputText = await document.GetTextAsync(DisposalToken); var position = inputText.GetPosition(input.Position); @@ -123,7 +113,6 @@ private async Task VerifyFindAllReferencesAsync(TestCode input, bool supportsVSE { if (result.TryGetFirst(out var referenceItem)) { - Assert.True(supportsVSExtensions); if (referenceItem.DisplayPath is not null) { Assert.False(referenceItem.DisplayPath.EndsWith(".g.cs")); @@ -134,10 +123,6 @@ private async Task VerifyFindAllReferencesAsync(TestCode input, bool supportsVSE Assert.False(referenceItem.DocumentName.EndsWith(".g.cs")); } } - else - { - Assert.False(supportsVSExtensions); - } } foreach (var result in results) @@ -171,7 +156,7 @@ private static string GetText(VSInternalReferenceItem referenceItem) return string.Join("", classifiedText.Runs.Select(s => s.Text)); } - return referenceItem.Text.AssumeNotNull().ToString(); + return referenceItem.Text.AssumeNotNull().ToString()!; } private static LspLocation GetLocation(SumType r) diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFoldingRangeEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostFoldingRangeEndpointTest.cs similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostFoldingRangeEndpointTest.cs rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostFoldingRangeEndpointTest.cs diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToDefinitionEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostGoToDefinitionEndpointTest.cs similarity index 99% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToDefinitionEndpointTest.cs rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostGoToDefinitionEndpointTest.cs index 94dd6c071ca..e9b44ee47c0 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToDefinitionEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostGoToDefinitionEndpointTest.cs @@ -430,8 +430,7 @@ private async Task VerifyGoToDefinitionAsync( var requestInvoker = new TestHtmlRequestInvoker([(Methods.TextDocumentDefinitionName, htmlResponse)]); - var filePathService = new VisualStudioFilePathService(FeatureOptions); - var endpoint = new CohostGoToDefinitionEndpoint(IncompatibleProjectService, RemoteServiceInvoker, requestInvoker, filePathService); + var endpoint = new CohostGoToDefinitionEndpoint(IncompatibleProjectService, RemoteServiceInvoker, requestInvoker, FilePathService); var textDocumentPositionParams = new TextDocumentPositionParams { diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostGoToImplementationEndpointTest.cs similarity index 100% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostGoToImplementationEndpointTest.cs rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostGoToImplementationEndpointTest.cs diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlayHintEndpointTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostInlayHintEndpointTest.cs similarity index 99% rename from src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlayHintEndpointTest.cs rename to src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostInlayHintEndpointTest.cs index b82c20a8ffd..1fb3fb43141 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostInlayHintEndpointTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/Shared/CohostInlayHintEndpointTest.cs @@ -173,7 +173,6 @@ public Task PageDirective() """); [Fact] - [System.ComponentModel.Description("Desc")] public Task AttributeDirective() => VerifyInlayHintsAsync( input: """ diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs index 672e7658562..bcf4bfb5857 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/CohostEndpointTestBase.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor; using Microsoft.CodeAnalysis.Razor.Remote; +using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Razor.Workspaces.Settings; using Microsoft.CodeAnalysis.Remote.Razor; using Microsoft.VisualStudio.Composition; @@ -18,10 +19,11 @@ public abstract class CohostEndpointTestBase(ITestOutputHelper testOutputHelper) { private IClientSettingsManager? _clientSettingsManager; private VSCodeRemoteServiceInvoker? _remoteServiceInvoker; + private IFilePathService? _filePathService; private protected override IRemoteServiceInvoker RemoteServiceInvoker => _remoteServiceInvoker.AssumeNotNull(); - private protected override IClientSettingsManager ClientSettingsManager => _clientSettingsManager.AssumeNotNull(); + private protected override IFilePathService FilePathService => _filePathService.AssumeNotNull(); /// /// The export provider for Roslyn "devenv" services, if tests opt-in to using them @@ -42,6 +44,8 @@ protected override async Task InitializeAsync() AddDisposable(_remoteServiceInvoker); _clientSettingsManager = new ClientSettingsManager(); + + _filePathService = new VSCodeFilePathService(FeatureOptions); } private protected override RemoteClientLSPInitializationOptions GetRemoteClientLSPInitializationOptions() diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/MEFCompositionTest.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/MEFCompositionTest.cs index 96c3061e830..b8bc4751771 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/MEFCompositionTest.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/MEFCompositionTest.cs @@ -22,13 +22,13 @@ public void Composes() // There are known failures that are satisfied by Microsoft.CodeAnalysis.LanguageServer, which we don't reference Assert.Collection(errors, - e => AssertEx.Equal(""" + e => AssertEx.AssertEqualToleratingWhitespaceDifferences(""" Microsoft.CodeAnalysis.ExternalAccess.Pythia.PythiaSignatureHelpProvider.ctor(implementation): expected exactly 1 export matching constraints: Contract name: Microsoft.CodeAnalysis.ExternalAccess.Pythia.Api.IPythiaSignatureHelpProviderImplementation TypeIdentityName: Microsoft.CodeAnalysis.ExternalAccess.Pythia.Api.IPythiaSignatureHelpProviderImplementation but found 0. """, e), - e => AssertEx.Equal(""" + e => AssertEx.AssertEqualToleratingWhitespaceDifferences(""" Microsoft.VisualStudioCode.RazorExtension.Services.WorkspaceService.ctor(loggerFactory): expected exactly 1 export matching constraints: Contract name: Microsoft.Extensions.Logging.ILoggerFactory TypeIdentityName: Microsoft.Extensions.Logging.ILoggerFactory diff --git a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/RazorWorkspaceListenerTest.cs b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/RazorWorkspaceListenerTest.cs index 67db86dcdc1..fd3ac5a957d 100644 --- a/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/RazorWorkspaceListenerTest.cs +++ b/src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/RazorWorkspaceListenerTest.cs @@ -8,6 +8,7 @@ using System.IO.Pipelines; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor.Utilities; @@ -56,7 +57,7 @@ public async Task TwoProjectsAdded_OneWithDynamicFiles_SchedulesOneTask() Assert.Equal(1, listener.SerializeCalls[project2.Id]); } - [Fact] + [ConditionalFact(Is.Windows)] public async Task TwoProjectsAdded_SchedulesTwoTasks() { using var workspace = new AdhocWorkspace(CodeAnalysis.Host.Mef.MefHostServices.DefaultHost); @@ -166,7 +167,7 @@ public async Task DocumentAdded_SchedulesTask() Assert.Equal(1, listener.SerializeCalls[project.Id]); } - [Fact] + [ConditionalFact(Is.Windows)] public async Task DocumentAdded_WithDelay_SchedulesTwoTasks() { using var workspace = new AdhocWorkspace(CodeAnalysis.Host.Mef.MefHostServices.DefaultHost); @@ -209,7 +210,7 @@ public async Task ProjectAddedAndRemoved_DeferredInitialization_NoTasks() Assert.Empty(listener.SerializeCalls); } - [Fact] + [ConditionalFact(Is.Windows)] public async Task TestSerialization() { using var workspace = new AdhocWorkspace(CodeAnalysis.Host.Mef.MefHostServices.DefaultHost);