зеркало из https://github.com/dotnet/razor.git
Merge branch 'features/CLaSP' of github.com:dotnet/razor-tooling into CLaSP/Benchmarks
This commit is contained in:
Коммит
e543be6607
963
NOTICE.txt
963
NOTICE.txt
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -76,7 +76,6 @@
|
|||
<package pattern="humanizer.core" />
|
||||
<package pattern="iced" />
|
||||
<package pattern="icsharpcode.decompiler" />
|
||||
<package pattern="mediatr" />
|
||||
<package pattern="messagepack" />
|
||||
<package pattern="messagepack.annotations" />
|
||||
<package pattern="messagepackanalyzer" />
|
||||
|
@ -98,11 +97,6 @@
|
|||
<package pattern="nuget.solutionrestoremanager.interop" />
|
||||
<package pattern="nuget.versioning" />
|
||||
<package pattern="omnisharp.abstractions" />
|
||||
<package pattern="omnisharp.extensions.jsonrpc" />
|
||||
<package pattern="omnisharp.extensions.jsonrpc.generators" />
|
||||
<package pattern="omnisharp.extensions.languageprotocol" />
|
||||
<package pattern="omnisharp.extensions.languageserver" />
|
||||
<package pattern="omnisharp.extensions.languageserver.shared" />
|
||||
<package pattern="omnisharp.msbuild" />
|
||||
<package pattern="omnisharp.roslyn" />
|
||||
<package pattern="omnisharp.roslyn.csharp" />
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
-->
|
||||
<ItemGroup>
|
||||
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="MediatR.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="OmniSharp.Extensions.JsonRpc.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="OmniSharp.Extensions.LanguageProtocol.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="OmniSharp.Extensions.LanguageServer.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="OmniSharp.Extensions.LanguageServer.Shared.dll" CertificateName="3PartySHA2" />
|
||||
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="3PartySHA2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -8,3 +8,4 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.OmniSharpPlugin.StrongNamed, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Common.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
|
|
|
@ -5,19 +5,18 @@ using System;
|
|||
using System.ComponentModel.Composition;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
|
||||
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
|
||||
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage.MessageInterception;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
using Microsoft.VisualStudio.Utilities;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
|
||||
namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
||||
{
|
||||
[Export(typeof(MessageInterceptor))]
|
||||
[InterceptMethod(WorkspaceNames.SemanticTokensRefresh)]
|
||||
[InterceptMethod(Methods.WorkspaceSemanticTokensRefreshName)]
|
||||
[ContentType(RazorLSPConstants.CSharpContentTypeName)]
|
||||
internal class RazorCSharpSemanticTokensInterceptor : MessageInterceptor
|
||||
{
|
||||
|
@ -46,5 +45,11 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
|
||||
return InterceptionResult.NoChange;
|
||||
}
|
||||
|
||||
// A basic POCO which will handle the lack of data in the response.
|
||||
private class Unit
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Razor.LanguageServer;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -40,12 +41,16 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
|
||||
private readonly VisualStudioHostServicesProvider? _vsHostWorkspaceServicesProvider;
|
||||
private readonly object _shutdownLock;
|
||||
private RazorLanguageServer? _server;
|
||||
private RazorLanguageServerWrapper? _server;
|
||||
private IDisposable? _serverShutdownDisposable;
|
||||
private LogHubLoggerProvider? _loggerProvider;
|
||||
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
|
||||
|
||||
private const string RazorLSPLogLevel = "RAZOR_TRACE";
|
||||
|
||||
public event AsyncEventHandler<EventArgs>? StartAsync;
|
||||
public event AsyncEventHandler<EventArgs>? StopAsync;
|
||||
|
||||
[ImportingConstructor]
|
||||
public RazorLanguageServerClient(
|
||||
RazorLanguageServerCustomMessageTarget customTarget,
|
||||
|
@ -54,6 +59,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
ProjectConfigurationFilePathStore projectConfigurationFilePathStore,
|
||||
RazorLanguageServerLogHubLoggerProviderFactory logHubLoggerProviderFactory,
|
||||
LanguageServerFeatureOptions languageServerFeatureOptions,
|
||||
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
|
||||
[Import(AllowDefault = true)] VisualStudioHostServicesProvider? vsHostWorkspaceServicesProvider)
|
||||
{
|
||||
if (customTarget is null)
|
||||
|
@ -81,6 +87,11 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
throw new ArgumentNullException(nameof(logHubLoggerProviderFactory));
|
||||
}
|
||||
|
||||
if (projectSnapshotManagerDispatcher is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
|
||||
}
|
||||
|
||||
if (languageServerFeatureOptions is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(languageServerFeatureOptions));
|
||||
|
@ -94,6 +105,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
_languageServerFeatureOptions = languageServerFeatureOptions;
|
||||
_vsHostWorkspaceServicesProvider = vsHostWorkspaceServicesProvider;
|
||||
_shutdownLock = new object();
|
||||
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
|
||||
}
|
||||
|
||||
public string Name => RazorLSPConstants.RazorLanguageServerName;
|
||||
|
@ -115,13 +127,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
|
||||
public bool ShowNotificationOnInitializeFailed => true;
|
||||
|
||||
public event AsyncEventHandler<EventArgs>? StartAsync;
|
||||
public event AsyncEventHandler<EventArgs>? StopAsync
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public async Task<Connection?> ActivateAsync(CancellationToken token)
|
||||
{
|
||||
// Swap to background thread, nothing below needs to be done on the UI thread.
|
||||
|
@ -136,24 +141,15 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
// Initialize Logging Infrastructure
|
||||
_loggerProvider = (LogHubLoggerProvider)await _logHubLoggerProviderFactory.GetOrCreateAsync(LogFileIdentifier, token).ConfigureAwait(false);
|
||||
|
||||
_server = await RazorLanguageServer.CreateAsync(serverStream, serverStream, traceLevel, _languageServerFeatureOptions, ConfigureLanguageServer).ConfigureAwait(false);
|
||||
|
||||
// Fire and forget for Initialized. Need to allow the LSP infrastructure to run in order to actually Initialize.
|
||||
_ = _server.InitializedAsync(token);
|
||||
_server = await RazorLanguageServerWrapper.CreateAsync(serverStream, serverStream, traceLevel, _projectSnapshotManagerDispatcher, ConfigureLanguageServer, _languageServerFeatureOptions).ConfigureAwait(false);
|
||||
|
||||
var connection = new Connection(clientStream, clientStream);
|
||||
return connection;
|
||||
}
|
||||
|
||||
private void ConfigureLanguageServer(RazorLanguageServerBuilder builder)
|
||||
private void ConfigureLanguageServer(IServiceCollection serviceCollection)
|
||||
{
|
||||
if (builder is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
var services = builder.Services;
|
||||
services.AddLogging(logging =>
|
||||
serviceCollection.AddLogging(logging =>
|
||||
{
|
||||
logging.AddFilter<LogHubLoggerProvider>(level => true);
|
||||
logging.AddProvider(_loggerProvider);
|
||||
|
@ -162,7 +158,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
if (_vsHostWorkspaceServicesProvider != null)
|
||||
{
|
||||
var wrapper = new HostServicesProviderWrapper(_vsHostWorkspaceServicesProvider);
|
||||
services.AddSingleton<HostServicesProvider>(wrapper);
|
||||
serviceCollection.AddSingleton<HostServicesProvider>(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,41 +187,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
await Task.Delay(100, token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
lock (_shutdownLock)
|
||||
if (_server is not null)
|
||||
{
|
||||
if (_server is not null)
|
||||
{
|
||||
// Server still hasn't shutdown, attempt an ungraceful shutdown.
|
||||
_server.Dispose();
|
||||
// Server still hasn't shutdown, attempt an ungraceful shutdown.
|
||||
await _server.DisposeAsync();
|
||||
|
||||
ServerShutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnLoadedAsync()
|
||||
{
|
||||
await StartAsync.InvokeAsync(this, EventArgs.Empty).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public Task OnServerInitializedAsync()
|
||||
{
|
||||
_serverShutdownDisposable = _server!.OnShutdown.Subscribe((_) => ServerShutdown());
|
||||
|
||||
ServerStarted();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void ServerStarted()
|
||||
{
|
||||
_projectConfigurationFilePathStore.Changed += ProjectConfigurationFilePathStore_Changed;
|
||||
|
||||
var mappings = _projectConfigurationFilePathStore.GetMappings();
|
||||
foreach (var mapping in mappings)
|
||||
{
|
||||
var args = new ProjectConfigurationFilePathChangedEventArgs(mapping.Key, mapping.Value);
|
||||
ProjectConfigurationFilePathStore_Changed(this, args);
|
||||
ServerShutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,17 +222,17 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
{
|
||||
try
|
||||
{
|
||||
var parameter = new MonitorProjectConfigurationFilePathParams()
|
||||
{
|
||||
ProjectFilePath = args.ProjectFilePath,
|
||||
ConfigurationFilePath = args.ConfigurationFilePath,
|
||||
};
|
||||
var parameter = new MonitorProjectConfigurationFilePathParams()
|
||||
{
|
||||
ProjectFilePath = args.ProjectFilePath,
|
||||
ConfigurationFilePath = args.ConfigurationFilePath,
|
||||
};
|
||||
|
||||
await _requestInvoker.ReinvokeRequestOnServerAsync<MonitorProjectConfigurationFilePathParams, object>(
|
||||
LanguageServerConstants.RazorMonitorProjectConfigurationFilePathEndpoint,
|
||||
RazorLSPConstants.RazorLanguageServerName,
|
||||
parameter,
|
||||
cancellationToken);
|
||||
await _requestInvoker.ReinvokeRequestOnServerAsync<MonitorProjectConfigurationFilePathParams, object>(
|
||||
LanguageServerConstants.RazorMonitorProjectConfigurationFilePathEndpoint,
|
||||
RazorLSPConstants.RazorLanguageServerName,
|
||||
parameter,
|
||||
cancellationToken);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -295,6 +262,30 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
return Task.FromResult<InitializationFailureContext?>(initializationFailureContext);
|
||||
}
|
||||
|
||||
public Task OnLoadedAsync()
|
||||
{
|
||||
return StartAsync.InvokeAsync(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public Task OnServerInitializedAsync()
|
||||
{
|
||||
ServerStarted();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void ServerStarted()
|
||||
{
|
||||
_projectConfigurationFilePathStore.Changed += ProjectConfigurationFilePathStore_Changed;
|
||||
|
||||
var mappings = _projectConfigurationFilePathStore.GetMappings();
|
||||
foreach (var mapping in mappings)
|
||||
{
|
||||
var args = new ProjectConfigurationFilePathChangedEventArgs(mapping.Key, mapping.Value);
|
||||
ProjectConfigurationFilePathStore_Changed(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
private class HostServicesProviderWrapper : HostServicesProvider
|
||||
{
|
||||
private readonly VisualStudioHostServicesProvider _vsHostServicesProvider;
|
||||
|
|
|
@ -5,14 +5,12 @@ using System;
|
|||
using System.Composition;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer;
|
||||
using Microsoft.CodeAnalysis.Razor.Editor;
|
||||
using Microsoft.VisualStudio.Editor.Razor;
|
||||
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using DidChangeConfigurationParams = OmniSharp.Extensions.LanguageServer.Protocol.Models.DidChangeConfigurationParams;
|
||||
|
||||
namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
||||
{
|
||||
|
@ -68,5 +66,10 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
|
|||
var isRazorLanguageServer = RazorLanguageServerCapability.TryGet(token, out _);
|
||||
return isRazorLanguageServer;
|
||||
}
|
||||
|
||||
private class Unit
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,11 +77,6 @@
|
|||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer.Protocol\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.LanguageServer.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Common\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.Common.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\MediatR.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\OmniSharp.Extensions.JsonRpc.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\OmniSharp.Extensions.LanguageProtocol.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\OmniSharp.Extensions.LanguageServer.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\OmniSharp.Extensions.LanguageServer.Shared.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Configuration.Binder.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Options.dll" />
|
||||
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Options.ConfigurationExtensions.dll" />
|
||||
|
|
|
@ -15,12 +15,6 @@
|
|||
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.dll" />
|
||||
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.Common.dll" />
|
||||
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
|
||||
<Import assembly="MediatR.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.JsonRpc.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.LanguageProtocol.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.LanguageServer.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.LanguageServer.Shared.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Configuration.Binder.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Options.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Options.ConfigurationExtensions.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Primitives.dll" />
|
||||
|
|
|
@ -15,12 +15,6 @@
|
|||
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.dll" />
|
||||
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.Common.dll" />
|
||||
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
|
||||
<Import assembly="MediatR.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.JsonRpc.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.LanguageProtocol.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.LanguageServer.dll" />
|
||||
<Import assembly="OmniSharp.Extensions.LanguageServer.Shared.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Configuration.Binder.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Options.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Options.ConfigurationExtensions.dll" />
|
||||
<Import assembly="Microsoft.Extensions.Primitives.dll" />
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\MediatR.dll")]
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.JsonRpc.dll")]
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.LanguageProtocol.dll")]
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.LanguageServer.dll")]
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.LanguageServer.Shared.dll")]
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Options.dll")]
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Primitives.dll")]
|
||||
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.DependencyInjection.dll")]
|
||||
|
|
|
@ -138,11 +138,6 @@
|
|||
NOTE: Adding OSS components to this list must be reviewed against our component governance standards. For now this is a curated list. You can read more about the CG process at https://aka.ms/component-governance
|
||||
***************************************************************************************************************************************
|
||||
-->
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)MediatR.dll" />
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.JsonRpc.dll" />
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.LanguageProtocol.dll" />
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.LanguageServer.dll" />
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.LanguageServer.Shared.dll" />
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Options.dll" />
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Options.ConfigurationExtensions.dll" />
|
||||
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Primitives.dll" />
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.Language.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="MediatR.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.JsonRpc.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.LanguageProtocol.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.LanguageServer.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.LanguageServer.Shared.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Configuration.Binder.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Options.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Options.ConfigurationExtensions.dll" />
|
||||
|
|
|
@ -11,6 +11,8 @@ using Microsoft.AspNetCore.Mvc.Razor.Extensions;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Common.Extensions;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Test.Common;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
@ -18,9 +20,11 @@ using Microsoft.CodeAnalysis.ExternalAccess.Razor;
|
|||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.CommonLanguageServerProtocol.Framework;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
using Moq;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
|
@ -36,10 +40,15 @@ namespace Microsoft.AspNetCore.Razor.Test.Common
|
|||
var logger = new Mock<ILogger>(MockBehavior.Strict).Object;
|
||||
Mock.Get(logger).Setup(l => l.Log(It.IsAny<LogLevel>(), It.IsAny<EventId>(), It.IsAny<It.IsAnyType>(), It.IsAny<Exception>(), It.IsAny<Func<It.IsAnyType, Exception?, string>>())).Verifiable();
|
||||
Mock.Get(logger).Setup(l => l.IsEnabled(It.IsAny<LogLevel>())).Returns(false);
|
||||
|
||||
LoggerFactory = TestLoggerFactory.Instance;
|
||||
Serializer = new LspSerializer();
|
||||
Serializer.RegisterRazorConverters();
|
||||
Serializer.RegisterVSInternalExtensionConverters();
|
||||
LspLogger = TestLspLogger.Instance;
|
||||
Logger = TestLspLogger.Instance;
|
||||
|
||||
Serializer = new JsonSerializer();
|
||||
Serializer.Converters.RegisterRazorConverters();
|
||||
Serializer.AddVSInternalExtensionConverters();
|
||||
Serializer.AddVSExtensionConverters();
|
||||
}
|
||||
|
||||
// This is marked as legacy because in its current form it's being assigned a "TestProjectSnapshotManagerDispatcher" which takes the
|
||||
|
@ -53,17 +62,33 @@ namespace Microsoft.AspNetCore.Razor.Test.Common
|
|||
|
||||
internal FilePathNormalizer FilePathNormalizer { get; }
|
||||
|
||||
protected JsonSerializer Serializer { get; }
|
||||
|
||||
internal IRazorSpanMappingService SpanMappingService { get; }
|
||||
|
||||
protected LspSerializer Serializer { get; }
|
||||
protected ILspLogger LspLogger { get; } = TestLspLogger.Instance;
|
||||
|
||||
protected ILogger Logger { get; } = TestLspLogger.Instance;
|
||||
|
||||
protected ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
internal static RazorRequestContext CreateRazorRequestContext(DocumentContext? documentContext, ILspLogger? lspLogger = null, ILogger? logger = null, ILspServices? lspServices = null)
|
||||
{
|
||||
lspLogger ??= TestLspLogger.Instance;
|
||||
logger ??= TestLspLogger.Instance;
|
||||
lspServices ??= new Mock<ILspServices>(MockBehavior.Strict).Object;
|
||||
|
||||
var requestContext = new RazorRequestContext(documentContext, lspLogger, logger, lspServices);
|
||||
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
protected static RazorCodeDocument CreateCodeDocument(string text, IReadOnlyList<TagHelperDescriptor>? tagHelpers = null)
|
||||
{
|
||||
tagHelpers ??= Array.Empty<TagHelperDescriptor>();
|
||||
var sourceDocument = TestRazorSourceDocument.Create(text);
|
||||
var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, RazorProjectFileSystem.Create("C:/"), builder => {
|
||||
var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, RazorProjectFileSystem.Create("C:/"), builder =>
|
||||
{
|
||||
RazorExtensions.Register(builder);
|
||||
});
|
||||
var defaultImportDocument = TestRazorSourceDocument.Create(
|
||||
|
@ -81,6 +106,11 @@ namespace Microsoft.AspNetCore.Razor.Test.Common
|
|||
return CreateDocumentContextFactory(documentPath, codeDocument);
|
||||
}
|
||||
|
||||
internal static DocumentContext? CreateDocumentContext(Uri documentPath, RazorCodeDocument codeDocument, bool documentFound = true)
|
||||
{
|
||||
return documentFound ? TestDocumentContext.From(documentPath.GetAbsoluteOrUNCPath(), codeDocument, hostDocumentVersion: 1337) : null;
|
||||
}
|
||||
|
||||
internal static DocumentContextFactory CreateDocumentContextFactory(
|
||||
Uri documentPath,
|
||||
RazorCodeDocument codeDocument,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
|
@ -21,28 +20,10 @@ namespace Microsoft.AspNetCore.Razor.Test.Common
|
|||
{
|
||||
}
|
||||
|
||||
public ILogger CreateLogger(string categoryName) => new TestLogger();
|
||||
public ILogger CreateLogger(string categoryName) => new TestLspLogger();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
private class TestLogger : ILogger
|
||||
{
|
||||
public IDisposable BeginScope<TState>(TState state) => new DisposableScope();
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel) => true;
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
}
|
||||
|
||||
private class DisposableScope : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using Microsoft.CommonLanguageServerProtocol.Framework;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
public class TestLspLogger : ILspLogger, ILogger
|
||||
{
|
||||
public static readonly TestLspLogger Instance = new();
|
||||
|
||||
public void LogEndContext(string message, params object[] @params)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogError(string message, params object[] @params)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogException(Exception exception, string message = null, params object[] @params)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogInformation(string message, params object[] @params)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogStartContext(string message, params object[] @params)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogWarning(string message, params object[] @params)
|
||||
{
|
||||
}
|
||||
|
||||
public IDisposable BeginScope<TState>(TState state)
|
||||
{
|
||||
return new Disposable();
|
||||
}
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
}
|
||||
|
||||
private class Disposable : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче