From 19831e9f9880bc388d59471dd82abf161e163fb7 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 7 Nov 2024 14:02:30 +1100 Subject: [PATCH 1/3] Remove LanguageServerFlags These flags were explicitly not for the compiler, being not serialized, and hence don't really belong on RazorConfiguration. They also were only ever set in the VS layer --- .../src/Language/LanguageServerFlags.cs | 11 -------- .../src/Language/RazorConfiguration.cs | 8 ++---- .../LanguageServerFeatureOptions.cs | 5 ---- .../DefaultWindowsRazorProjectHost.cs | 26 ++++++------------- .../ProjectSystem/FallbackProjectManager.cs | 4 +-- 5 files changed, 11 insertions(+), 43 deletions(-) delete mode 100644 src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/LanguageServerFlags.cs diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/LanguageServerFlags.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/LanguageServerFlags.cs deleted file mode 100644 index 524aae94357..00000000000 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/LanguageServerFlags.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Razor.Language; - -/// -/// This class represents flags provided by the language server instead of project configuration. -/// They should not be serialized as part of the configuration, as they instead change runtime behavior -/// impacted by LSP configuration rather than any project configuration -/// -public sealed record class LanguageServerFlags(bool ForceRuntimeCodeGeneration); diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorConfiguration.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorConfiguration.cs index 83cd64698d1..01a9f6a1cd5 100644 --- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorConfiguration.cs +++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorConfiguration.cs @@ -12,23 +12,20 @@ public sealed record class RazorConfiguration( string ConfigurationName, ImmutableArray Extensions, bool UseConsolidatedMvcViews = true, - bool SuppressAddComponentParameter = false, - LanguageServerFlags? LanguageServerFlags = null) + bool SuppressAddComponentParameter = false) { public static readonly RazorConfiguration Default = new( RazorLanguageVersion.Latest, ConfigurationName: "unnamed", Extensions: [], UseConsolidatedMvcViews: true, - SuppressAddComponentParameter: false, - LanguageServerFlags: null); + SuppressAddComponentParameter: false); public bool Equals(RazorConfiguration? other) => other is not null && LanguageVersion == other.LanguageVersion && ConfigurationName == other.ConfigurationName && SuppressAddComponentParameter == other.SuppressAddComponentParameter && - LanguageServerFlags == other.LanguageServerFlags && UseConsolidatedMvcViews == other.UseConsolidatedMvcViews && Extensions.SequenceEqual(other.Extensions); @@ -40,7 +37,6 @@ public override int GetHashCode() hash.Add(Extensions); hash.Add(SuppressAddComponentParameter); hash.Add(UseConsolidatedMvcViews); - hash.Add(LanguageServerFlags); return hash; } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/LanguageServerFeatureOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/LanguageServerFeatureOptions.cs index f63e09cf7b9..aaeb22a42b0 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/LanguageServerFeatureOptions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/LanguageServerFeatureOptions.cs @@ -1,8 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT license. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Razor.Language; - namespace Microsoft.CodeAnalysis.Razor.Workspaces; internal abstract class LanguageServerFeatureOptions @@ -41,7 +39,4 @@ internal abstract class LanguageServerFeatureOptions /// When enabled, design time code will not be generated. All tooling will be using runtime code generation. /// public abstract bool ForceRuntimeCodeGeneration { get; } - - public LanguageServerFlags ToLanguageServerFlags() - => new(ForceRuntimeCodeGeneration); } diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs index 5b499fb9c44..177d32e035a 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs @@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor.ProjectSystem; -using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.VisualStudio.ProjectSystem; using Microsoft.VisualStudio.ProjectSystem.Properties; using Microsoft.VisualStudio.Shell; @@ -28,7 +27,12 @@ namespace Microsoft.VisualStudio.Razor.ProjectSystem; // MSBuild provides configuration support (>= 2.1). [AppliesTo("DotNetCoreRazor & DotNetCoreRazorConfiguration")] [Export(ExportContractNames.Scopes.UnconfiguredProject, typeof(IProjectDynamicLoadComponent))] -internal class DefaultWindowsRazorProjectHost : WindowsRazorProjectHostBase +[method: ImportingConstructor] +internal class DefaultWindowsRazorProjectHost( + IUnconfiguredProjectCommonServices commonServices, + [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, + IProjectSnapshotManager projectManager) + : WindowsRazorProjectHostBase(commonServices, serviceProvider, projectManager) { private const string RootNamespaceProperty = "RootNamespace"; private static readonly ImmutableHashSet s_ruleNames = ImmutableHashSet.CreateRange(new string[] @@ -40,24 +44,12 @@ internal class DefaultWindowsRazorProjectHost : WindowsRazorProjectHostBase Rules.RazorGenerateWithTargetPath.SchemaName, ConfigurationGeneralSchemaName, }); - private readonly LanguageServerFeatureOptions _languageServerFeatureOptions; - - [ImportingConstructor] - public DefaultWindowsRazorProjectHost( - IUnconfiguredProjectCommonServices commonServices, - [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, - IProjectSnapshotManager projectManager, - LanguageServerFeatureOptions languageServerFeatureOptions) - : base(commonServices, serviceProvider, projectManager) - { - _languageServerFeatureOptions = languageServerFeatureOptions; - } protected override ImmutableHashSet GetRuleNames() => s_ruleNames; protected override async Task HandleProjectChangeAsync(string sliceDimensions, IProjectVersionedValue update) { - if (TryGetConfiguration(update.Value.CurrentState, _languageServerFeatureOptions.ToLanguageServerFlags(), out var configuration) && + if (TryGetConfiguration(update.Value.CurrentState, out var configuration) && TryGetIntermediateOutputPath(update.Value.CurrentState, out var intermediatePath)) { TryGetRootNamespace(update.Value.CurrentState, out var rootNamespace); @@ -134,7 +126,6 @@ await UpdateAsync( // Internal for testing internal static bool TryGetConfiguration( IImmutableDictionary state, - LanguageServerFlags? languageServerFlags, [NotNullWhen(returnValue: true)] out RazorConfiguration? configuration) { if (!TryGetDefaultConfiguration(state, out var defaultConfiguration)) @@ -165,8 +156,7 @@ internal static bool TryGetConfiguration( configuration = new( languageVersion, configurationItem.Key, - extensions, - LanguageServerFlags: languageServerFlags); + extensions); return true; } diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackProjectManager.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackProjectManager.cs index 09130e8cb44..9fb36da3829 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackProjectManager.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackProjectManager.cs @@ -26,13 +26,11 @@ namespace Microsoft.VisualStudio.Razor.ProjectSystem; [method: ImportingConstructor] internal sealed class FallbackProjectManager( [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, - LanguageServerFeatureOptions languageServerFeatureOptions, IProjectSnapshotManager projectManager, IWorkspaceProvider workspaceProvider, ITelemetryReporter telemetryReporter) { private readonly IServiceProvider _serviceProvider = serviceProvider; - private readonly LanguageServerFeatureOptions _languageServerFeatureOptions = languageServerFeatureOptions; private readonly IProjectSnapshotManager _projectManager = projectManager; private readonly IWorkspaceProvider _workspaceProvider = workspaceProvider; private readonly ITelemetryReporter _telemetryReporter = telemetryReporter; @@ -108,7 +106,7 @@ private void AddFallbackProject(ProjectId projectId, string filePath, Cancellati var rootNamespace = project.DefaultNamespace; - var configuration = FallbackRazorConfiguration.Latest with { LanguageServerFlags = _languageServerFeatureOptions.ToLanguageServerFlags() }; + var configuration = FallbackRazorConfiguration.Latest; // We create this as a fallback project so that other parts of the system can reason about them - eg we don't do code // generation for closed files for documents in these projects. If these projects become "real", either because capabilities From 9d02758cd266f8ce2fa42e3e49cc38d9dd7ded1c Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 7 Nov 2024 14:03:08 +1100 Subject: [PATCH 2/3] Use LanguageServerFeatureOptions to get the language server feature option --- .../LspProjectSnapshotManager.cs | 4 +- .../DocumentState.ComputedStateTracker.cs | 2 +- .../ProjectSystem/ProjectSnapshot.cs | 2 + .../ProjectSystem/ProjectSnapshotManager.cs | 6 +++ .../ProjectSystem/ProjectState.cs | 50 ++++--------------- .../ProjectSystem/RemoteDocumentSnapshot.cs | 2 +- .../VisualStudioProjectSnapshotManager.cs | 4 +- 7 files changed, 25 insertions(+), 45 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs index faad24dbb7f..cb951779759 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs @@ -4,13 +4,15 @@ using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Razor.Workspaces; namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem; internal class LspProjectSnapshotManager( IProjectEngineFactoryProvider projectEngineFactoryProvider, + LanguageServerFeatureOptions languageServerFeatureOptions, ILoggerFactory loggerFactory) - : ProjectSnapshotManager(projectEngineFactoryProvider, loggerFactory, initializer: AddMiscFilesProject) + : ProjectSnapshotManager(projectEngineFactoryProvider, languageServerFeatureOptions, loggerFactory, initializer: AddMiscFilesProject) { private static void AddMiscFilesProject(Updater updater) { diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.ComputedStateTracker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.ComputedStateTracker.cs index 3c8cda5bd82..ffbd02c1127 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.ComputedStateTracker.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.ComputedStateTracker.cs @@ -233,7 +233,7 @@ static void PropagateToTaskCompletionSource( } var tagHelpers = await project.GetTagHelpersAsync(cancellationToken).ConfigureAwait(false); - var forceRuntimeCodeGeneration = project.Configuration.LanguageServerFlags?.ForceRuntimeCodeGeneration ?? false; + var forceRuntimeCodeGeneration = project.LanguageServerFeatureOptions.ForceRuntimeCodeGeneration; var codeDocument = await GenerateCodeDocumentAsync(document, project.GetProjectEngine(), imports, tagHelpers, forceRuntimeCodeGeneration, cancellationToken).ConfigureAwait(false); return (codeDocument, inputVersion); } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs index 8f844402e2e..01182938d7b 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.AspNetCore.Razor.Utilities; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor.Workspaces; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; @@ -23,6 +24,7 @@ internal sealed class ProjectSnapshot(ProjectState state) : IProjectSnapshot private readonly Dictionary _filePathToDocumentMap = new(FilePathNormalizingComparer.Instance); public HostProject HostProject => _state.HostProject; + public LanguageServerFeatureOptions LanguageServerFeatureOptions => _state.LanguageServerFeatureOptions; public ProjectKey Key => _state.HostProject.Key; public RazorConfiguration Configuration => _state.HostProject.Configuration; diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs index fc596af32dd..1436c39a5d4 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.AspNetCore.Razor.Threading; using Microsoft.CodeAnalysis.Razor.Logging; +using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; @@ -27,6 +28,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; internal partial class ProjectSnapshotManager : IProjectSnapshotManager, IDisposable { private readonly IProjectEngineFactoryProvider _projectEngineFactoryProvider; + private readonly LanguageServerFeatureOptions _languageServerFeatureOptions; private readonly Dispatcher _dispatcher; private readonly bool _initialized; @@ -64,16 +66,19 @@ internal partial class ProjectSnapshotManager : IProjectSnapshotManager, IDispos /// /// The to /// use when creating . + /// The options that were used to start the language server /// The to use. /// An optional callback to set up the initial set of projects and documents. /// Note that this is called during construction, so it does not run on the dispatcher and notifications /// will not be sent. public ProjectSnapshotManager( IProjectEngineFactoryProvider projectEngineFactoryProvider, + LanguageServerFeatureOptions languageServerFeatureOptions, ILoggerFactory loggerFactory, Action? initializer = null) { _projectEngineFactoryProvider = projectEngineFactoryProvider; + _languageServerFeatureOptions = languageServerFeatureOptions; _dispatcher = new(loggerFactory); initializer?.Invoke(new(this)); @@ -437,6 +442,7 @@ private bool TryUpdate( var state = ProjectState.Create( _projectEngineFactoryProvider, + _languageServerFeatureOptions, hostProject, ProjectWorkspaceState.Default); diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs index 9e753414420..6a09502c957 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.AspNetCore.Razor.Utilities; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; @@ -35,37 +36,26 @@ internal class ProjectState private readonly object _lock; private readonly IProjectEngineFactoryProvider _projectEngineFactoryProvider; + private readonly LanguageServerFeatureOptions _languageServerFeatureOptions; private RazorProjectEngine? _projectEngine; public static ProjectState Create( IProjectEngineFactoryProvider projectEngineFactoryProvider, + LanguageServerFeatureOptions languageServerFeatureOptions, HostProject hostProject, ProjectWorkspaceState projectWorkspaceState) { - if (projectEngineFactoryProvider is null) - { - throw new ArgumentNullException(nameof(projectEngineFactoryProvider)); - } - - if (hostProject is null) - { - throw new ArgumentNullException(nameof(hostProject)); - } - - if (projectWorkspaceState is null) - { - throw new ArgumentNullException(nameof(projectWorkspaceState)); - } - - return new ProjectState(projectEngineFactoryProvider, hostProject, projectWorkspaceState); + return new ProjectState(projectEngineFactoryProvider, languageServerFeatureOptions, hostProject, projectWorkspaceState); } private ProjectState( IProjectEngineFactoryProvider projectEngineFactoryProvider, + LanguageServerFeatureOptions languageServerFeatureOptions, HostProject hostProject, ProjectWorkspaceState projectWorkspaceState) { _projectEngineFactoryProvider = projectEngineFactoryProvider; + _languageServerFeatureOptions = languageServerFeatureOptions; HostProject = hostProject; ProjectWorkspaceState = projectWorkspaceState; Documents = s_emptyDocuments; @@ -85,32 +75,8 @@ private ProjectState( ImmutableDictionary documents, ImmutableDictionary> importsToRelatedDocuments) { - if (older is null) - { - throw new ArgumentNullException(nameof(older)); - } - - if (hostProject is null) - { - throw new ArgumentNullException(nameof(hostProject)); - } - - if (documents is null) - { - throw new ArgumentNullException(nameof(documents)); - } - - if (importsToRelatedDocuments is null) - { - throw new ArgumentNullException(nameof(importsToRelatedDocuments)); - } - - if (projectWorkspaceState is null) - { - throw new ArgumentNullException(nameof(projectWorkspaceState)); - } - _projectEngineFactoryProvider = older._projectEngineFactoryProvider; + _languageServerFeatureOptions = older._languageServerFeatureOptions; Version = older.Version.GetNewerVersion(); HostProject = hostProject; @@ -169,6 +135,8 @@ private ProjectState( public HostProject HostProject { get; } + internal LanguageServerFeatureOptions LanguageServerFeatureOptions => _languageServerFeatureOptions; + public ProjectWorkspaceState ProjectWorkspaceState { get; } public ImmutableArray TagHelpers => ProjectWorkspaceState.TagHelpers; 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 8231e30a12f..39f2e9d2830 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteDocumentSnapshot.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteDocumentSnapshot.cs @@ -103,7 +103,7 @@ async Task GetRazorCodeDocumentAsync(bool forceRuntimeCodeGen var imports = await DocumentState.GetImportsAsync(this, projectEngine, cancellationToken).ConfigureAwait(false); return await DocumentState - .GenerateCodeDocumentAsync(this, projectEngine, imports, tagHelpers, forceRuntimeCodeGeneration: forceRuntimeCodeGeneration, cancellationToken) + .GenerateCodeDocumentAsync(this, projectEngine, imports, tagHelpers, forceRuntimeCodeGeneration, cancellationToken) .ConfigureAwait(false); } } diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/VisualStudioProjectSnapshotManager.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/VisualStudioProjectSnapshotManager.cs index 1a792129fb0..3d7a6b947d5 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/VisualStudioProjectSnapshotManager.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/VisualStudioProjectSnapshotManager.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Razor.Workspaces; namespace Microsoft.VisualStudio.Razor.ProjectSystem; @@ -12,7 +13,8 @@ namespace Microsoft.VisualStudio.Razor.ProjectSystem; [method: ImportingConstructor] internal sealed class VisualStudioProjectSnapshotManager( IProjectEngineFactoryProvider projectEngineFactoryProvider, + LanguageServerFeatureOptions languageServerFeatureOptions, ILoggerFactory loggerFactory) - : ProjectSnapshotManager(projectEngineFactoryProvider, loggerFactory) + : ProjectSnapshotManager(projectEngineFactoryProvider, languageServerFeatureOptions, loggerFactory) { } From 87c016397444a0fa1d93a87d0591c044bfe15a89 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Thu, 7 Nov 2024 14:03:16 +1100 Subject: [PATCH 3/3] Update tests and benchmark --- .../ProjectSnapshotManagerBenchmarkBase.cs | 2 + .../ProjectEngineFactoryProviderTest.cs | 13 ++-- .../LanguageServer/LanguageServerTestBase.cs | 3 +- .../ProjectSystem/TestProjectSnapshot.cs | 3 +- .../TestProjectSnapshotManager.cs | 4 +- .../ToolingTestBase.cs | 6 ++ .../DocumentExcerptServiceTestBase.cs | 2 +- .../Workspaces/WorkspaceTestBase.cs | 19 +++++- .../DefaultDocumentSnapshotTest.cs | 2 +- .../DefaultProjectSnapshotTest.cs | 6 +- .../GeneratedDocumentTextLoaderTest.cs | 2 +- .../ProjectStateGeneratedOutputTest.cs | 18 ++--- .../ProjectSystem/ProjectStateTest.cs | 68 +++++++++---------- .../RazorSpanMappingServiceTest.cs | 8 +-- .../RazorDocumentOptionsServiceTest.cs | 2 +- .../DefaultWindowsRazorProjectHostTest.cs | 37 +++++----- .../FallbackProjectManagerTest.cs | 1 - .../RazorDynamicFileInfoProviderTest.cs | 1 - .../ProjectWorkspaceStateGeneratorTest.cs | 2 +- 19 files changed, 112 insertions(+), 87 deletions(-) diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/ProjectSystem/ProjectSnapshotManagerBenchmarkBase.cs b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/ProjectSystem/ProjectSnapshotManagerBenchmarkBase.cs index d8ab181d8d9..0e40658d013 100644 --- a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/ProjectSystem/ProjectSnapshotManagerBenchmarkBase.cs +++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/ProjectSystem/ProjectSnapshotManagerBenchmarkBase.cs @@ -4,6 +4,7 @@ using System.Collections.Immutable; using System.IO; using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.LanguageServer; using Microsoft.AspNetCore.Razor.PooledObjects; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor.Logging; @@ -53,6 +54,7 @@ internal ProjectSnapshotManager CreateProjectSnapshotManager() { return new ProjectSnapshotManager( projectEngineFactoryProvider: StaticProjectEngineFactoryProvider.Instance, + languageServerFeatureOptions: new DefaultLanguageServerFeatureOptions(), loggerFactory: EmptyLoggerFactory.Instance); } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.ProjectEngineHost.Test/ProjectEngineFactoryProviderTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.ProjectEngineHost.Test/ProjectEngineFactoryProviderTest.cs index 6b0c2f43966..c27bec75298 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.ProjectEngineHost.Test/ProjectEngineFactoryProviderTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.ProjectEngineHost.Test/ProjectEngineFactoryProviderTest.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.AspNetCore.Razor.Test.Common; +using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Xunit; @@ -49,12 +50,12 @@ public ProjectEngineFactoryProviderTest(ITestOutputHelper testOutput) projectFilePath, intermediateOutputPath, new(RazorLanguageVersion.Version_2_1, "Random-0.1", Extensions: []), rootNamespace: null); - _snapshot_For_1_0 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, hostProject_For_1_0, ProjectWorkspaceState.Default)); - _snapshot_For_1_1 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, hostProject_For_1_1, ProjectWorkspaceState.Default)); - _snapshot_For_2_0 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, hostProject_For_2_0, ProjectWorkspaceState.Default)); - _snapshot_For_2_1 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, hostProject_For_2_1, ProjectWorkspaceState.Default)); - _snapshot_For_3_0 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, hostProject_For_3_0, ProjectWorkspaceState.Default)); - _snapshot_For_UnknownConfiguration = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, hostProject_For_UnknownConfiguration, ProjectWorkspaceState.Default)); + _snapshot_For_1_0 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, TestLanguageServerFeatureOptions.Instance, hostProject_For_1_0, ProjectWorkspaceState.Default)); + _snapshot_For_1_1 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, TestLanguageServerFeatureOptions.Instance, hostProject_For_1_1, ProjectWorkspaceState.Default)); + _snapshot_For_2_0 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, TestLanguageServerFeatureOptions.Instance, hostProject_For_2_0, ProjectWorkspaceState.Default)); + _snapshot_For_2_1 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, TestLanguageServerFeatureOptions.Instance, hostProject_For_2_1, ProjectWorkspaceState.Default)); + _snapshot_For_3_0 = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, TestLanguageServerFeatureOptions.Instance, hostProject_For_3_0, ProjectWorkspaceState.Default)); + _snapshot_For_UnknownConfiguration = new ProjectSnapshot(ProjectState.Create(ProjectEngineFactories.DefaultProvider, TestLanguageServerFeatureOptions.Instance, hostProject_For_UnknownConfiguration, ProjectWorkspaceState.Default)); _customFactories = [ diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs index 72cdaffb7fd..1d8a762a586 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs @@ -49,9 +49,10 @@ protected LanguageServerTestBase(ITestOutputHelper testOutput) } private protected override TestProjectSnapshotManager CreateProjectSnapshotManager( - IProjectEngineFactoryProvider projectEngineFactoryProvider) + IProjectEngineFactoryProvider projectEngineFactoryProvider, LanguageServerFeatureOptions languageServerFeatureOptions) => new( projectEngineFactoryProvider, + languageServerFeatureOptions, LoggerFactory, DisposalToken, initializer: static updater => updater.ProjectAdded(MiscFilesHostProject.Instance)); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs index 731bf4a98dd..b49cfd224fb 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshot.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.AspNetCore.Razor.ProjectSystem; +using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Razor.ProjectSystem; @@ -30,7 +31,7 @@ public static TestProjectSnapshot Create(string filePath, ProjectWorkspaceState? var hostProject = TestHostProject.Create(filePath); projectWorkspaceState ??= ProjectWorkspaceState.Default; - var state = ProjectState.Create(ProjectEngineFactories.DefaultProvider, hostProject, projectWorkspaceState); + var state = ProjectState.Create(ProjectEngineFactories.DefaultProvider, TestLanguageServerFeatureOptions.Instance, hostProject, projectWorkspaceState); return new TestProjectSnapshot(state); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshotManager.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshotManager.cs index 06ae2133870..7d273a0e7c0 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshotManager.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ProjectSystem/TestProjectSnapshotManager.cs @@ -7,15 +7,17 @@ using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.CodeAnalysis.Razor.Workspaces; namespace Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; internal partial class TestProjectSnapshotManager( IProjectEngineFactoryProvider projectEngineFactoryProvider, + LanguageServerFeatureOptions languageServerFeatureOptions, ILoggerFactory loggerFactory, CancellationToken disposalToken, Action? initializer = null) - : ProjectSnapshotManager(projectEngineFactoryProvider, loggerFactory, initializer) + : ProjectSnapshotManager(projectEngineFactoryProvider, languageServerFeatureOptions, loggerFactory, initializer) { private readonly CancellationToken _disposalToken = disposalToken; diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ToolingTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ToolingTestBase.cs index 09d784274ab..00ecb453199 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ToolingTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/ToolingTestBase.cs @@ -8,7 +8,9 @@ using Microsoft.AspNetCore.Razor.ProjectEngineHost; using Microsoft.AspNetCore.Razor.Test.Common.Logging; using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; +using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.CodeAnalysis.Razor.Logging; +using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.VisualStudio.Threading; using Xunit; using Xunit.Abstractions; @@ -221,8 +223,12 @@ private protected virtual TestProjectSnapshotManager CreateProjectSnapshotManage => CreateProjectSnapshotManager(ProjectEngineFactories.DefaultProvider); private protected virtual TestProjectSnapshotManager CreateProjectSnapshotManager(IProjectEngineFactoryProvider projectEngineFactoryProvider) + => CreateProjectSnapshotManager(projectEngineFactoryProvider, TestLanguageServerFeatureOptions.Instance); + + private protected virtual TestProjectSnapshotManager CreateProjectSnapshotManager(IProjectEngineFactoryProvider projectEngineFactoryProvider, LanguageServerFeatureOptions languageServerFeatureOptions) => new( projectEngineFactoryProvider, + languageServerFeatureOptions, LoggerFactory, DisposalToken); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/DocumentExcerptServiceTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/DocumentExcerptServiceTestBase.cs index f013c6cab13..f156b67a393 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/DocumentExcerptServiceTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/DocumentExcerptServiceTestBase.cs @@ -42,7 +42,7 @@ public static (SourceText sourceText, TextSpan span) CreateText(string text) private (IDocumentSnapshot primary, Document secondary) InitializeDocument(SourceText sourceText) { var state = ProjectState - .Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader(sourceText, VersionStamp.Create())); var project = new ProjectSnapshot(state); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/WorkspaceTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/WorkspaceTestBase.cs index fb683bd8fe0..2fda7392cb3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/WorkspaceTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/Workspaces/WorkspaceTestBase.cs @@ -20,6 +20,7 @@ public abstract class WorkspaceTestBase(ITestOutputHelper testOutput) : ToolingT private Workspace? _workspace; private IWorkspaceProvider? _workspaceProvider; private IProjectEngineFactoryProvider? _projectEngineFactoryProvider; + private LanguageServerFeatureOptions? _languageServerFeatureOptions; protected HostServices HostServices { @@ -57,8 +58,20 @@ private protected IProjectEngineFactoryProvider ProjectEngineFactoryProvider } } + private protected LanguageServerFeatureOptions LanguageServerFeatureOptions + { + get + { + EnsureInitialized(); + return _languageServerFeatureOptions; + } + } + private protected override TestProjectSnapshotManager CreateProjectSnapshotManager() - => CreateProjectSnapshotManager(ProjectEngineFactoryProvider); + => CreateProjectSnapshotManager(ProjectEngineFactoryProvider, LanguageServerFeatureOptions); + + private protected override TestProjectSnapshotManager CreateProjectSnapshotManager(IProjectEngineFactoryProvider projectEngineFactoryProvider) + => base.CreateProjectSnapshotManager(projectEngineFactoryProvider, LanguageServerFeatureOptions); protected virtual void ConfigureWorkspace(AdhocWorkspace workspace) { @@ -68,7 +81,7 @@ protected virtual void ConfigureProjectEngine(RazorProjectEngineBuilder builder) { } - [MemberNotNull(nameof(_hostServices), nameof(_workspace), nameof(_workspaceProvider), nameof(_projectEngineFactoryProvider))] + [MemberNotNull(nameof(_hostServices), nameof(_workspace), nameof(_workspaceProvider), nameof(_projectEngineFactoryProvider), nameof(_languageServerFeatureOptions))] private void EnsureInitialized() { if (_initialized) @@ -77,6 +90,7 @@ private void EnsureInitialized() _workspace.AssumeNotNull(); _workspaceProvider.AssumeNotNull(); _projectEngineFactoryProvider.AssumeNotNull(); + _languageServerFeatureOptions.AssumeNotNull(); return; } @@ -89,6 +103,7 @@ private void EnsureInitialized() _workspace = TestWorkspace.Create(_hostServices, ConfigureWorkspace); AddDisposable(_workspace); _workspaceProvider = new TestWorkspaceProvider(_workspace); + _languageServerFeatureOptions = TestLanguageServerFeatureOptions.Instance; _initialized = true; } diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultDocumentSnapshotTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultDocumentSnapshotTest.cs index 8fb1c912ad6..9384e08a414 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultDocumentSnapshotTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultDocumentSnapshotTest.cs @@ -33,7 +33,7 @@ public DefaultDocumentSnapshotTest(ITestOutputHelper testOutput) _sourceText = SourceText.From("

Hello World

"); _version = VersionStamp.Create(); - var projectState = ProjectState.Create(ProjectEngineFactoryProvider, TestProjectData.SomeProject, ProjectWorkspaceState.Default); + var projectState = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, TestProjectData.SomeProject, ProjectWorkspaceState.Default); var project = new ProjectSnapshot(projectState); var textLoader = TestMocks.CreateTextLoader(_sourceText, _version); diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs index 9cb9d299dfa..eb351a5d6f4 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs @@ -44,7 +44,7 @@ protected override void ConfigureProjectEngine(RazorProjectEngineBuilder builder public void ProjectSnapshot_CachesDocumentSnapshots() { // Arrange - var state = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var state = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader); @@ -65,7 +65,7 @@ public void ProjectSnapshot_CachesDocumentSnapshots() public void GetRelatedDocuments_NonImportDocument_ReturnsEmpty() { // Arrange - var state = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var state = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader); var snapshot = new ProjectSnapshot(state); @@ -83,7 +83,7 @@ public void GetRelatedDocuments_NonImportDocument_ReturnsEmpty() public void GetRelatedDocuments_ImportDocument_ReturnsRelated() { // Arrange - var state = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var state = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader); diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/GeneratedDocumentTextLoaderTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/GeneratedDocumentTextLoaderTest.cs index edc944332d8..be6725ad0df 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/GeneratedDocumentTextLoaderTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/GeneratedDocumentTextLoaderTest.cs @@ -30,7 +30,7 @@ public async Task LoadAsync_SpecifiesEncoding() { // Arrange var project = new ProjectSnapshot( - ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader("", VersionStamp.Create()))); var document = project.GetDocument(_hostDocument.FilePath); diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateGeneratedOutputTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateGeneratedOutputTest.cs index 7e80b2537b7..7dd40de1843 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateGeneratedOutputTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateGeneratedOutputTest.cs @@ -43,7 +43,7 @@ public async Task HostDocumentAdded_CachesOutput() { // Arrange var original = - ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader); var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument, DisposalToken); @@ -62,7 +62,7 @@ public async Task HostDocumentAdded_Import_DoesNotCacheOutput() { // Arrange var original = - ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader); var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument, DisposalToken); @@ -82,7 +82,7 @@ public async Task HostDocumentChanged_DoesNotCacheOutput() { // Arrange var original = ProjectState - .Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader); @@ -104,7 +104,7 @@ public async Task HostDocumentChanged_Import_DoesNotCacheOutput() { // Arrange var original = ProjectState - .Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader); @@ -126,7 +126,7 @@ public async Task HostDocumentRemoved_Import_DoesNotCacheOutput() { // Arrange var original = - ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader); @@ -147,7 +147,7 @@ public async Task ProjectWorkspaceStateChange_CachesOutput_EvenWhenNewerProjectW { // Arrange var original = - ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader); var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument, DisposalToken); @@ -168,7 +168,7 @@ public async Task ProjectWorkspaceStateChange_WithTagHelperChange_DoesNotCacheOu { // Arrange var original = - ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader); var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument, DisposalToken); @@ -192,7 +192,7 @@ public async Task ProjectWorkspaceStateChange_WithProjectWorkspaceState_CSharpLa var hostProject = TestProjectData.SomeProject with { Configuration = csharp8ValidConfiguration }; var originalWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, LanguageVersion.CSharp7); var original = - ProjectState.Create(ProjectEngineFactoryProvider, hostProject, originalWorkspaceState) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, hostProject, originalWorkspaceState) .WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader("@DateTime.Now", VersionStamp.Default)); var changedWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, LanguageVersion.CSharp8); @@ -213,7 +213,7 @@ public async Task ConfigurationChange_DoesNotCacheOutput() { // Arrange var original = - ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader); var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument, DisposalToken); diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs index 2658d893683..f1c3eb75efa 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs @@ -56,7 +56,7 @@ protected override void ConfigureProjectEngine(RazorProjectEngineBuilder builder public void GetImportDocumentTargetPaths_DoesNotIncludeCurrentImport() { // Arrange - var state = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var state = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); // Act var paths = state.GetImportDocumentTargetPaths(TestProjectData.SomeProjectComponentImportFile1); @@ -71,7 +71,7 @@ public void ProjectState_ConstructedNew() // Arrange // Act - var state = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var state = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); // Assert Assert.Empty(state.Documents); @@ -82,7 +82,7 @@ public void ProjectState_ConstructedNew() public void ProjectState_AddHostDocument_ToEmpty() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); // Act var state = original.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader); @@ -100,7 +100,7 @@ public void ProjectState_AddHostDocument_ToEmpty() public async Task ProjectState_AddHostDocument_DocumentIsEmpty() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); // Act var state = original.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader); @@ -114,7 +114,7 @@ public async Task ProjectState_AddHostDocument_DocumentIsEmpty() public void ProjectState_AddHostDocument_ToProjectWithDocuments() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -138,7 +138,7 @@ public void ProjectState_AddHostDocument_TracksImports() // Arrange // Act - var state = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var state = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader) @@ -177,7 +177,7 @@ public void ProjectState_AddHostDocument_TracksImports() public void ProjectState_AddHostDocument_TracksImports_AddImportFile() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader) @@ -220,7 +220,7 @@ public void ProjectState_AddHostDocument_TracksImports_AddImportFile() public void ProjectState_AddHostDocument_RetainsComputedState() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -253,7 +253,7 @@ public void ProjectState_AddHostDocument_RetainsComputedState() public void ProjectState_AddHostDocument_DuplicateNoops() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -268,7 +268,7 @@ public void ProjectState_AddHostDocument_DuplicateNoops() public async Task ProjectState_WithChangedHostDocument_Loader() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -288,7 +288,7 @@ public async Task ProjectState_WithChangedHostDocument_Loader() public async Task ProjectState_WithChangedHostDocument_Snapshot() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -308,7 +308,7 @@ public async Task ProjectState_WithChangedHostDocument_Snapshot() public void ProjectState_WithChangedHostDocument_Loader_RetainsComputedState() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -340,7 +340,7 @@ public void ProjectState_WithChangedHostDocument_Loader_RetainsComputedState() public void ProjectState_WithChangedHostDocument_Snapshot_RetainsComputedState() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -372,7 +372,7 @@ public void ProjectState_WithChangedHostDocument_Snapshot_RetainsComputedState() public void ProjectState_WithChangedHostDocument_Loader_NotFoundNoops() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -387,7 +387,7 @@ public void ProjectState_WithChangedHostDocument_Loader_NotFoundNoops() public void ProjectState_WithChangedHostDocument_Snapshot_NotFoundNoops() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -402,7 +402,7 @@ public void ProjectState_WithChangedHostDocument_Snapshot_NotFoundNoops() public void ProjectState_RemoveHostDocument_FromProjectWithDocuments() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -423,7 +423,7 @@ public void ProjectState_RemoveHostDocument_FromProjectWithDocuments() public void ProjectState_RemoveHostDocument_TracksImports() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader) @@ -463,7 +463,7 @@ public void ProjectState_RemoveHostDocument_TracksImports() public void ProjectState_RemoveHostDocument_TracksImports_RemoveAllDocuments() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader) .WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader) @@ -485,7 +485,7 @@ public void ProjectState_RemoveHostDocument_TracksImports_RemoveAllDocuments() public void ProjectState_RemoveHostDocument_RetainsComputedState() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -517,7 +517,7 @@ public void ProjectState_RemoveHostDocument_RetainsComputedState() public void ProjectState_RemoveHostDocument_NotFoundNoops() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -532,7 +532,7 @@ public void ProjectState_RemoveHostDocument_NotFoundNoops() public void ProjectState_WithHostProject_ConfigurationChange_UpdatesConfigurationState() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -570,7 +570,7 @@ public void ProjectState_WithHostProject_ConfigurationChange_UpdatesConfiguratio public void ProjectState_WithHostProject_RootNamespaceChange_UpdatesConfigurationState() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); var hostProjectWithRootNamespaceChange = original.HostProject with { RootNamespace = "ChangedRootNamespace" }; @@ -590,7 +590,7 @@ public void ProjectState_WithHostProject_RootNamespaceChange_UpdatesConfiguratio public void ProjectState_WithHostProject_NoConfigurationChange_Noops() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -614,7 +614,7 @@ public void ProjectState_WithHostProject_CallsConfigurationChangeOnDocumentState documents[_documents[1].FilePath] = TestDocumentState.Create(_documents[1], onConfigurationChange: () => callCount++); documents[_documents[2].FilePath] = TestDocumentState.Create(_documents[2], onConfigurationChange: () => callCount++); - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original.Documents = documents.ToImmutable(); // Act @@ -630,7 +630,7 @@ public void ProjectState_WithHostProject_CallsConfigurationChangeOnDocumentState public void ProjectState_WithHostProject_ResetsImportedDocuments() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original = original.WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader); // Act @@ -646,7 +646,7 @@ public void ProjectState_WithHostProject_ResetsImportedDocuments() public void ProjectState_WithProjectWorkspaceState_Changed() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -685,7 +685,7 @@ public void ProjectState_WithProjectWorkspaceState_Changed() public void ProjectState_WithProjectWorkspaceState_Changed_TagHelpersChanged() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -719,7 +719,7 @@ public void ProjectState_WithProjectWorkspaceState_Changed_TagHelpersChanged() public void ProjectState_WithProjectWorkspaceState_IdenticalState_Caches() { // Arrange - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState) + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState) .WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader) .WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader); @@ -746,7 +746,7 @@ public void ProjectState_WithProjectWorkspaceState_CallsWorkspaceProjectChangeOn documents[_documents[1].FilePath] = TestDocumentState.Create(_documents[1], onProjectWorkspaceStateChange: () => callCount++); documents[_documents[2].FilePath] = TestDocumentState.Create(_documents[2], onProjectWorkspaceStateChange: () => callCount++); - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original.Documents = documents.ToImmutable(); var changed = ProjectWorkspaceState.Default; @@ -790,7 +790,7 @@ public void ProjectState_WhenImportDocumentAdded_CallsImportsChanged() TestProjectData.SomeProjectNestedFile3.FilePath, TestProjectData.AnotherProjectNestedFile4.FilePath)); - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original.Documents = documents.ToImmutable(); original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable(); @@ -833,7 +833,7 @@ public void ProjectState_WhenImportDocumentAdded_CallsImportsChanged_Nested() TestProjectData.SomeProjectNestedFile3.FilePath, TestProjectData.AnotherProjectNestedFile4.FilePath)); - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original.Documents = documents.ToImmutable(); original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable(); @@ -879,7 +879,7 @@ public void ProjectState_WhenImportDocumentChangedTextLoader_CallsImportsChanged TestProjectData.SomeProjectNestedFile3.FilePath, TestProjectData.AnotherProjectNestedFile4.FilePath)); - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original.Documents = documents.ToImmutable(); original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable(); @@ -925,7 +925,7 @@ public void ProjectState_WhenImportDocumentChangedSnapshot_CallsImportsChanged() TestProjectData.SomeProjectNestedFile3.FilePath, TestProjectData.AnotherProjectNestedFile4.FilePath)); - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original.Documents = documents.ToImmutable(); original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable(); @@ -971,7 +971,7 @@ public void ProjectState_WhenImportDocumentRemoved_CallsImportsChanged() TestProjectData.SomeProjectNestedFile3.FilePath, TestProjectData.AnotherProjectNestedFile4.FilePath)); - var original = ProjectState.Create(ProjectEngineFactoryProvider, _hostProject, _projectWorkspaceState); + var original = ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, _projectWorkspaceState); original.Documents = documents.ToImmutable(); original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable(); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DynamicFiles/RazorSpanMappingServiceTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DynamicFiles/RazorSpanMappingServiceTest.cs index b793ecc1080..e578d1e9b6f 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DynamicFiles/RazorSpanMappingServiceTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/DynamicFiles/RazorSpanMappingServiceTest.cs @@ -30,7 +30,7 @@ public async Task TryGetMappedSpans_SpanMatchesSourceMapping_ReturnsTrue() "); var project = new ProjectSnapshot(ProjectState - .Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader(sourceText, VersionStamp.Create()))); var document = project.GetDocument(_hostDocument.FilePath); @@ -62,7 +62,7 @@ public async Task TryGetMappedSpans_SpanMatchesSourceMappingAndPosition_ReturnsT "); var project = new ProjectSnapshot(ProjectState - .Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader(sourceText, VersionStamp.Create()))); var document = project.GetDocument(_hostDocument.FilePath); @@ -95,7 +95,7 @@ public async Task TryGetMappedSpans_SpanWithinSourceMapping_ReturnsTrue() "); var project = new ProjectSnapshot(ProjectState - .Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader(sourceText, VersionStamp.Create()))); var document = project.GetDocument(_hostDocument.FilePath); @@ -127,7 +127,7 @@ public async Task TryGetMappedSpans_SpanOutsideSourceMapping_ReturnsFalse() "); var project = new ProjectSnapshot(ProjectState - .Create(ProjectEngineFactoryProvider, _hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, _hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(_hostDocument, TestMocks.CreateTextLoader(sourceText, VersionStamp.Create()))); var document = project.GetDocument(_hostDocument.FilePath); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs index 9e6c078dd94..2f0c0042866 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/LanguageClient/RazorDocumentOptionsServiceTest.cs @@ -97,7 +97,7 @@ private Document InitializeDocument(SourceText sourceText) Path.Combine(baseDirectory, "SomeProject", "File1.cshtml"), "File1.cshtml", FileKinds.Legacy); var project = new ProjectSnapshot(ProjectState - .Create(ProjectEngineFactoryProvider, hostProject, ProjectWorkspaceState.Default) + .Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, hostProject, ProjectWorkspaceState.Default) .WithAddedHostDocument(hostDocument, TestMocks.CreateTextLoader(sourceText, VersionStamp.Create()))); var documentSnapshot = project.GetDocument(hostDocument.FilePath); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultWindowsRazorProjectHostTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultWindowsRazorProjectHostTest.cs index 99ebb5d5cc9..eb8c5cb1bd1 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultWindowsRazorProjectHostTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/DefaultWindowsRazorProjectHostTest.cs @@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem; using Microsoft.AspNetCore.Razor.Test.Common.VisualStudio; -using Microsoft.AspNetCore.Razor.Test.Common.Workspaces; using Microsoft.VisualStudio.ProjectSystem.Properties; using Xunit; using Xunit.Abstractions; @@ -451,7 +450,7 @@ public void TryGetConfiguration_FailsIfNoDefaultConfiguration() var projectState = new Dictionary().ToImmutableDictionary(); // Act - var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, languageServerFlags: null, out var configuration); + var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, out var configuration); // Assert Assert.False(result); @@ -473,7 +472,7 @@ public void TryGetConfiguration_FailsIfNoLanguageVersion() }.ToImmutableDictionary(); // Act - var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, languageServerFlags: null, out var configuration); + var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, out var configuration); // Assert Assert.False(result); @@ -496,7 +495,7 @@ public void TryGetConfiguration_FailsIfNoConfigurationItems() }.ToImmutableDictionary(); // Act - var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, languageServerFlags: null, out var configuration); + var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, out var configuration); // Assert Assert.False(result); @@ -525,7 +524,7 @@ public void TryGetConfiguration_SucceedsWithNoConfiguredExtensionNames() }.ToImmutableDictionary(); // Act - var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, languageServerFlags: null, out var configuration); + var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, out var configuration); // Assert Assert.True(result); @@ -559,7 +558,7 @@ public void TryGetConfiguration_IgnoresMissingExtension() }.ToImmutableDictionary(); // Act - var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, languageServerFlags: null, out var configuration); + var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, out var configuration); // Assert Assert.True(result); @@ -607,7 +606,7 @@ public void TryGetConfiguration_SucceedsWithAllPreRequisites() }.ToImmutableDictionary(); // Act - var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, languageServerFlags: null, out var configuration); + var result = DefaultWindowsRazorProjectHost.TryGetConfiguration(projectState, out var configuration); // Assert Assert.True(result); @@ -624,7 +623,7 @@ public async Task DefaultRazorProjectHost_UIThread_CreateAndDispose_Succeeds() { // Arrange var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); // Act & Assert await host.LoadAsync(); @@ -639,7 +638,7 @@ public async Task DefaultRazorProjectHost_BackgroundThread_CreateAndDispose_Succ { // Arrange var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); // Act & Assert await Task.Run(async () => await host.LoadAsync()); @@ -658,7 +657,7 @@ public async Task DefaultRazorProjectHost_OnProjectChanged_NoRulesDefined() }; var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); // Act & Assert await Task.Run(async () => await host.LoadAsync()); @@ -702,7 +701,7 @@ public async Task OnProjectChanged_ReadsProperties_InitializesProject() var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); host.SkipIntermediateOutputPathExistCheck_TestOnly = true; await Task.Run(async () => await host.LoadAsync()); @@ -755,7 +754,7 @@ public async Task OnProjectChanged_ReadsProperties_InitializesProject() public void IntermediateOutputPathCalculationHandlesRelativePaths(string baseIntermediateOutputPath, string intermediateOutputPath, string expectedCombinedIOP) { var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); var state = TestProjectRuleSnapshot.CreateProperties( WindowsRazorProjectHostBase.ConfigurationGeneralSchemaName, @@ -798,7 +797,7 @@ public async Task OnProjectChanged_NoVersionFound_DoesNotInitializeProject() }; var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); await Task.Run(async () => await host.LoadAsync()); Assert.Empty(_projectManager.GetProjects()); @@ -849,7 +848,7 @@ public async Task OnProjectChanged_UpdateProject_MarksSolutionOpen() }; var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); host.SkipIntermediateOutputPathExistCheck_TestOnly = true; await Task.Run(async () => await host.LoadAsync()); @@ -903,7 +902,7 @@ public async Task OnProjectChanged_UpdateProject_Succeeds() }; var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); host.SkipIntermediateOutputPathExistCheck_TestOnly = true; await Task.Run(async () => await host.LoadAsync()); @@ -1059,7 +1058,7 @@ public async Task OnProjectChanged_VersionRemoved_DeInitializesProject() }; var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); host.SkipIntermediateOutputPathExistCheck_TestOnly = true; await Task.Run(async () => await host.LoadAsync()); @@ -1134,7 +1133,7 @@ public async Task OnProjectChanged_AfterDispose_IgnoresUpdate() }; var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); host.SkipIntermediateOutputPathExistCheck_TestOnly = true; await Task.Run(async () => await host.LoadAsync()); @@ -1214,7 +1213,7 @@ public async Task OnProjectRenamed_RemovesHostProject_CopiesConfiguration() var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); host.SkipIntermediateOutputPathExistCheck_TestOnly = true; await Task.Run(async () => await host.LoadAsync()); @@ -1311,7 +1310,7 @@ public async Task OnProjectChanged_ChangeIntermediateOutputPath_RemovesAndAddsPr }; var services = new TestProjectSystemServices(TestProjectData.SomeProject.FilePath); - var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager, languageServerFeatureOptions: new TestLanguageServerFeatureOptions()); + var host = new DefaultWindowsRazorProjectHost(services, _serviceProvider, _projectManager); host.SkipIntermediateOutputPathExistCheck_TestOnly = true; await Task.Run(async () => await host.LoadAsync()); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/FallbackProjectManagerTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/FallbackProjectManagerTest.cs index 43c28f4e8d0..57d07c5b993 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/FallbackProjectManagerTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/FallbackProjectManagerTest.cs @@ -39,7 +39,6 @@ public FallbackProjectManagerTest(ITestOutputHelper testOutputHelper) _fallbackProjectManger = new FallbackProjectManager( serviceProvider, - languageServerFeatureOptions, _projectManager, WorkspaceProvider, NoOpTelemetryReporter.Instance); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/RazorDynamicFileInfoProviderTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/RazorDynamicFileInfoProviderTest.cs index d749db5e6ae..ff1fa77965d 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/RazorDynamicFileInfoProviderTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectSystem/RazorDynamicFileInfoProviderTest.cs @@ -73,7 +73,6 @@ await _projectManager.UpdateAsync(updater => var fallbackProjectManager = new FallbackProjectManager( serviceProvider, - languageServerFeatureOptions, _projectManager, WorkspaceProvider, NoOpTelemetryReporter.Instance); diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectWorkspaceStateGeneratorTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectWorkspaceStateGeneratorTest.cs index ac3cc9ee050..c1dca22323f 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectWorkspaceStateGeneratorTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/ProjectWorkspaceStateGeneratorTest.cs @@ -42,7 +42,7 @@ public ProjectWorkspaceStateGeneratorTest(ITestOutputHelper testOutput) TestProjectData.SomeProject.FilePath)); _workspaceProject = solution.GetProject(projectId).AssumeNotNull(); _projectSnapshot = new ProjectSnapshot( - ProjectState.Create(ProjectEngineFactoryProvider, TestProjectData.SomeProject, ProjectWorkspaceState.Default)); + ProjectState.Create(ProjectEngineFactoryProvider, LanguageServerFeatureOptions, TestProjectData.SomeProject, ProjectWorkspaceState.Default)); _projectWorkspaceStateWithTagHelpers = ProjectWorkspaceState.Create( [TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()]);