This commit is contained in:
David Wengier 2024-09-16 14:28:12 +10:00
Родитель f3a633bf3a
Коммит 4207fcf417
4 изменённых файлов: 8 добавлений и 17 удалений

Просмотреть файл

@ -11,14 +11,12 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer;
internal sealed class AdhocWorkspaceFactory(IHostServicesProvider hostServicesProvider) : IAdhocWorkspaceFactory
{
public AdhocWorkspace Create(params IWorkspaceService[] workspaceServices)
public AdhocWorkspace Create()
{
workspaceServices ??= [];
var fallbackServices = hostServicesProvider.GetServices();
var services = AdhocServices.Create(
workspaceServices: workspaceServices.ToImmutableArray(),
languageServices: ImmutableArray<ILanguageService>.Empty,
workspaceServices: [],
languageServices: [],
fallbackServices);
return new AdhocWorkspace(services);

Просмотреть файл

@ -1,11 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
internal interface IAdhocWorkspaceFactory
{
AdhocWorkspace Create(params IWorkspaceService[] workspaceServices);
AdhocWorkspace Create();
}

Просмотреть файл

@ -1,9 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Composition;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.CodeAnalysis.Remote.Razor;
@ -11,13 +9,12 @@ namespace Microsoft.CodeAnalysis.Remote.Razor;
[Export(typeof(IAdhocWorkspaceFactory)), Shared]
internal sealed class RemoteAdhocWorkspaceFactory() : IAdhocWorkspaceFactory
{
public AdhocWorkspace Create(params IWorkspaceService[] workspaceServices)
public AdhocWorkspace Create()
{
workspaceServices ??= [];
var hostServices = RemoteWorkspaceAccessor.GetWorkspace().Services.HostServices;
var services = AdhocServices.Create(
workspaceServices: workspaceServices.ToImmutableArray(),
workspaceServices: [],
languageServices: [],
fallbackServices: hostServices);

Просмотреть файл

@ -1,10 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Linq;
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Test;
@ -17,9 +15,9 @@ internal class TestAdhocWorkspaceFactory : IAdhocWorkspaceFactory
{
}
public AdhocWorkspace Create(params IWorkspaceService[] workspaceServices)
public AdhocWorkspace Create()
{
var services = TestServices.Create(workspaceServices, Enumerable.Empty<ILanguageService>());
var services = TestServices.Create(workspaceServices: [], razorLanguageServices: []);
var workspace = TestWorkspace.Create(services);
return workspace;
}