зеркало из https://github.com/dotnet/razor.git
This reverts commitb16dc7981c
, reversing changes made tob2d2ec9802
.
This commit is contained in:
Родитель
3135e699cf
Коммит
a6e050f46b
|
@ -8,10 +8,10 @@
|
|||
<_MicrosoftWebToolsPackageVersion>17.9.67-preview-0001</_MicrosoftWebToolsPackageVersion>
|
||||
<_MicrosoftVisualStudioShellPackagesVersion>17.9.36524</_MicrosoftVisualStudioShellPackagesVersion>
|
||||
<_MicrosoftVisualStudioPackagesVersion>17.10.72-preview</_MicrosoftVisualStudioPackagesVersion>
|
||||
<_VisualStudioLanguageServerProtocolVersion>17.10.34-preview</_VisualStudioLanguageServerProtocolVersion>
|
||||
<_VisualStudioLanguageServerProtocolVersion>17.10.13-preview</_VisualStudioLanguageServerProtocolVersion>
|
||||
<_MicrosoftExtensionsPackageVersion>8.0.0</_MicrosoftExtensionsPackageVersion>
|
||||
<_BenchmarkDotNetPackageVersion>0.13.5.2136</_BenchmarkDotNetPackageVersion>
|
||||
<_MicrosoftVisualStudioExtensibilityTestingVersion>0.1.187-beta</_MicrosoftVisualStudioExtensibilityTestingVersion>
|
||||
<_MicrosoftVisualStudioExtensibilityTestingVersion>0.1.169-beta</_MicrosoftVisualStudioExtensibilityTestingVersion>
|
||||
<_MicrosoftCodeAnalysisAnalyzersPackageVersion>3.11.0-beta1.24170.2</_MicrosoftCodeAnalysisAnalyzersPackageVersion>
|
||||
<_MicrosoftVisualStudioLanguageServicesPackageVersion>$(MicrosoftVisualStudioLanguageServicesPackageVersion)</_MicrosoftVisualStudioLanguageServicesPackageVersion>
|
||||
<_XunitPackageVersion>2.6.3</_XunitPackageVersion>
|
||||
|
@ -67,7 +67,7 @@
|
|||
<PackageVersion Include="Microsoft.Internal.VisualStudio.Interop" Version="$(_MicrosoftVisualStudioShellPackagesVersion)" />
|
||||
<PackageVersion Include="Microsoft.NET.Sdk.Razor" Version="$(MicrosoftNETSdkRazorPackageVersion)" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.Copilot" Version="0.2.28-beta" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.ComponentModelHost" Version="17.10.29-preview" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.ComponentModelHost" Version="17.10.9-preview" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.Editor" Version="$(_MicrosoftVisualStudioPackagesVersion)" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.Extensibility.Testing.Xunit" Version="$(_MicrosoftVisualStudioExtensibilityTestingVersion)" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.Extensibility.Testing.SourceGenerator" Version="$(_MicrosoftVisualStudioExtensibilityTestingVersion)" />
|
||||
|
@ -76,10 +76,10 @@
|
|||
<PackageVersion Include="Microsoft.VisualStudio.Language.Intellisense" Version="$(_MicrosoftVisualStudioPackagesVersion)" />
|
||||
<!--
|
||||
This package should use _VisualStudioLanguageServerProtocolVersion, but as of updating there was
|
||||
a mismatch in published versions (17.10.108-preview was not published).Next time this is updated please switch back to
|
||||
_VisualStudioLanguageServerProtocolVersion if possible
|
||||
-->
|
||||
<PackageVersion Include="Microsoft.VisualStudio.LanguageServer.Client.Implementation" Version="17.10.108-preview" />
|
||||
a mismatch in published versions (17.10.13-preview was not published). Next time this is updated please switch back to
|
||||
_VisualStudioLanguageServerProtocolVersion if possible
|
||||
-->
|
||||
<PackageVersion Include="Microsoft.VisualStudio.LanguageServer.Client.Implementation" Version="17.10.16-preview" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.LanguageServer.Protocol" Version="$(_VisualStudioLanguageServerProtocolVersion)" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.LanguageServer.Protocol.Extensions" Version="$(_VisualStudioLanguageServerProtocolVersion)" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.LanguageServer.Protocol.Internal" Version="$(_VisualStudioLanguageServerProtocolVersion)" />
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Composition;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.VisualStudio.LanguageServer.Client;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
|
@ -47,16 +47,15 @@ internal class DefaultLSPRequestInvoker : LSPRequestInvoker
|
|||
_serializer.AddVSInternalExtensionConverters();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public override Task<IEnumerable<ReinvokeResponse<TOut>>> ReinvokeRequestOnMultipleServersAsync<TIn, TOut>(string method, string contentType, TIn parameters, CancellationToken cancellationToken)
|
||||
{
|
||||
return RequestMultipleServerCoreAsync<TIn, TOut>(method, parameters, cancellationToken);
|
||||
var capabilitiesFilter = _fallbackCapabilitiesFilterResolver.Resolve(method);
|
||||
return RequestMultipleServerCoreAsync<TIn, TOut>(method, contentType, capabilitiesFilter, parameters, cancellationToken);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public override Task<IEnumerable<ReinvokeResponse<TOut>>> ReinvokeRequestOnMultipleServersAsync<TIn, TOut>(string method, string contentType, Func<JToken, bool> capabilitiesFilter, TIn parameters, CancellationToken cancellationToken)
|
||||
{
|
||||
return RequestMultipleServerCoreAsync<TIn, TOut>(method, parameters, cancellationToken);
|
||||
return RequestMultipleServerCoreAsync<TIn, TOut>(method, contentType, capabilitiesFilter, parameters, cancellationToken);
|
||||
}
|
||||
|
||||
public override Task<ReinvokeResponse<TOut>> ReinvokeRequestOnServerAsync<TIn, TOut>(
|
||||
|
@ -82,12 +81,17 @@ internal class DefaultLSPRequestInvoker : LSPRequestInvoker
|
|||
}
|
||||
|
||||
var serializedParams = JToken.FromObject(parameters);
|
||||
var response = await _languageServiceBroker.RequestAsync(
|
||||
new GeneralRequest<TIn, TOut> { LanguageServerName = languageServerName, Method = method, Request = parameters },
|
||||
#pragma warning disable CS0618 // Type or member is obsolete. Temporary until we resolve the changes to the ILanguageServiceBroker2 interface.
|
||||
var (languageClient, resultToken) = await _languageServiceBroker.RequestAsync(
|
||||
Array.Empty<string>(),
|
||||
capabilitiesFilter,
|
||||
languageServerName,
|
||||
method,
|
||||
serializedParams,
|
||||
cancellationToken);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
// No callers actually use the languageClient when handling the response.
|
||||
var result = response is not null ? new ReinvokeResponse<TOut>(languageClient:null!, response) : default;
|
||||
var result = resultToken is not null ? new ReinvokeResponse<TOut>(languageClient!, resultToken.ToObject<TOut>(_serializer)!) : default;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -105,26 +109,38 @@ internal class DefaultLSPRequestInvoker : LSPRequestInvoker
|
|||
TIn parameters,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var serializedParams = JToken.FromObject(parameters);
|
||||
JToken ParameterFactory(ITextSnapshot _)
|
||||
{
|
||||
return serializedParams;
|
||||
}
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete. Temporary until we resolve the changes to the ILanguageServiceBroker2 interface.
|
||||
var response = await _languageServiceBroker.RequestAsync(
|
||||
new DocumentRequest<TIn, TOut>()
|
||||
{
|
||||
TextBuffer = textBuffer,
|
||||
LanguageServerName = languageServerName,
|
||||
ParameterFactory = _ => parameters,
|
||||
Method = method,
|
||||
},
|
||||
textBuffer,
|
||||
capabilitiesFilter,
|
||||
languageServerName,
|
||||
method,
|
||||
ParameterFactory,
|
||||
cancellationToken);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
if (response is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var reinvocationResponse = new ReinvocationResponse<TOut>(languageServerName, response);
|
||||
var responseBody = default(TOut);
|
||||
if (response.Response is not null)
|
||||
{
|
||||
responseBody = response.Response.ToObject<TOut>(_serializer);
|
||||
}
|
||||
|
||||
var reinvocationResponse = new ReinvocationResponse<TOut>(response.LanguageClientName, responseBody);
|
||||
return reinvocationResponse;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<ReinvokeResponse<TOut>>> RequestMultipleServerCoreAsync<TIn, TOut>(string method, TIn parameters, CancellationToken cancellationToken)
|
||||
private async Task<IEnumerable<ReinvokeResponse<TOut>>> RequestMultipleServerCoreAsync<TIn, TOut>(string method, string contentType, Func<JToken, bool> capabilitiesFilter, TIn parameters, CancellationToken cancellationToken)
|
||||
where TIn : notnull
|
||||
{
|
||||
if (string.IsNullOrEmpty(method))
|
||||
|
@ -132,18 +148,21 @@ internal class DefaultLSPRequestInvoker : LSPRequestInvoker
|
|||
throw new ArgumentException("message", nameof(method));
|
||||
}
|
||||
|
||||
var reinvokeResponses = _languageServiceBroker.RequestAllAsync(
|
||||
new GeneralRequest<TIn, TOut>() { LanguageServerName = null, Method = method, Request = parameters},
|
||||
var serializedParams = JToken.FromObject(parameters);
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var clientAndResultTokenPairs = await _languageServiceBroker.RequestMultipleAsync(
|
||||
new[] { contentType },
|
||||
capabilitiesFilter,
|
||||
method,
|
||||
serializedParams,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
using var _ = ListPool<ReinvokeResponse<TOut>>.GetPooledObject(out var responses);
|
||||
await foreach (var reinvokeResponse in reinvokeResponses)
|
||||
{
|
||||
// No callers actually use the languageClient when handling the response.
|
||||
responses.Add(new ReinvokeResponse<TOut>(languageClient:null!, reinvokeResponse.response!));
|
||||
}
|
||||
// a little ugly - tuple deconstruction in lambda arguments doesn't work - https://github.com/dotnet/csharplang/issues/258
|
||||
var results = clientAndResultTokenPairs.Select((clientAndResultToken) => clientAndResultToken.Item2 is not null ? new ReinvokeResponse<TOut>(clientAndResultToken.Item1, clientAndResultToken.Item2.ToObject<TOut>(_serializer)!) : default);
|
||||
|
||||
return responses.ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
public override IAsyncEnumerable<ReinvocationResponse<TOut>> ReinvokeRequestOnMultipleServersAsync<TIn, TOut>(
|
||||
|
@ -163,13 +182,27 @@ internal class DefaultLSPRequestInvoker : LSPRequestInvoker
|
|||
TIn parameters,
|
||||
[EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
var requests = _languageServiceBroker.RequestAllAsync(
|
||||
new DocumentRequest<TIn, TOut> { ParameterFactory = _ => parameters, Method = method, TextBuffer = textBuffer },
|
||||
var serializedParams = JToken.FromObject(parameters);
|
||||
Func<ITextSnapshot, JToken> parameterFactory = (_) => serializedParams;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete. Temporary until we resolve the changes to the ILanguageServiceBroker2 interface.
|
||||
var requests = _languageServiceBroker.RequestMultipleAsync(
|
||||
textBuffer,
|
||||
capabilitiesFilter,
|
||||
method,
|
||||
parameterFactory,
|
||||
cancellationToken);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
await foreach (var response in requests)
|
||||
{
|
||||
yield return new ReinvocationResponse<TOut>(response.client, response.response);
|
||||
var responseBody = default(TOut);
|
||||
if (response.Response is not null)
|
||||
{
|
||||
responseBody = response.Response.ToObject<TOut>(_serializer);
|
||||
var reinvocationResponse = new ReinvocationResponse<TOut>(response.LanguageClientName, responseBody);
|
||||
yield return reinvocationResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ internal abstract class LSPRequestInvoker
|
|||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>When operating on a document the <see cref="ITextBuffer"/> overload should be used, since it guarantees ordering.</remarks>
|
||||
[Obsolete("New callers should use a method that returns a ReinvocationResponse rather than an a ReinvokeResponse")]
|
||||
public abstract Task<IEnumerable<ReinvokeResponse<TOut>>> ReinvokeRequestOnMultipleServersAsync<TIn, TOut>(
|
||||
string method,
|
||||
string contentType,
|
||||
|
@ -98,7 +97,6 @@ internal abstract class LSPRequestInvoker
|
|||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>When operating on a document the <see cref="ITextBuffer"/> overload should be used, since it guarantees ordering.</remarks>
|
||||
[Obsolete("New callers should use a method that returns a ReinvocationResponse rather than an a ReinvokeResponse")]
|
||||
public abstract Task<IEnumerable<ReinvokeResponse<TOut>>> ReinvokeRequestOnMultipleServersAsync<TIn, TOut>(
|
||||
string method,
|
||||
string contentType,
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage.MessageInterce
|
|||
/// Receives notification messages from the server and invokes any applicable message interception layers.
|
||||
/// </summary>
|
||||
#pragma warning disable CS0618 // Type or member is obsolete. Temporary for compatibility with ILanguageClientMiddleLayer
|
||||
public class InterceptionMiddleLayer : ILanguageClientMiddleLayer, ILanguageClientMiddleLayer2<JToken>
|
||||
public class InterceptionMiddleLayer : ILanguageClientMiddleLayer
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
private readonly InterceptorManager _interceptorManager;
|
||||
|
|
|
@ -9,7 +9,7 @@ using Newtonsoft.Json.Linq;
|
|||
namespace Microsoft.VisualStudio.Razor.LanguageClient;
|
||||
|
||||
[Export(typeof(RazorLanguageClientMiddleLayer))]
|
||||
internal class DefaultRazorLanguageClientMiddleLayer : RazorLanguageClientMiddleLayer //, ILanguageClientMiddleLayer2<JToken>
|
||||
internal class DefaultRazorLanguageClientMiddleLayer : RazorLanguageClientMiddleLayer
|
||||
{
|
||||
public override bool CanHandle(string methodName) => false;
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class DefaultLSPRequestInvokerTest : ToolingTestBase
|
|||
|
||||
// Assert
|
||||
Assert.True(called);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CustomRequestServerAsync_InvokesHtmlLanguageClient()
|
||||
|
@ -156,9 +156,9 @@ public class DefaultLSPRequestInvokerTest : ToolingTestBase
|
|||
{
|
||||
var broker = new StrictMock<ILanguageServiceBroker2>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
broker.Setup(b => b.RequestAsync(It.IsAny<Request<object,object>>(), It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync((null))
|
||||
.Callback((Request<object,object> request, CancellationToken _) => callback(request.Method));
|
||||
broker.Setup(b => b.RequestAsync(It.IsAny<string[]>(), It.IsAny<Func<JToken, bool>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<JToken>(), It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync((null, null))
|
||||
.Callback((string[] _, Func<JToken, bool> _, string _, string method, JToken _, CancellationToken _) => callback(method));
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
return broker.Object;
|
||||
|
|
|
@ -30,7 +30,6 @@ internal class TestLSPRequestInvoker : LSPRequestInvoker
|
|||
_csharpServer = csharpServer;
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public override Task<IEnumerable<ReinvokeResponse<TOut>>> ReinvokeRequestOnMultipleServersAsync<TIn, TOut>(
|
||||
string method,
|
||||
string contentType,
|
||||
|
@ -40,7 +39,6 @@ internal class TestLSPRequestInvoker : LSPRequestInvoker
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public override Task<IEnumerable<ReinvokeResponse<TOut>>> ReinvokeRequestOnMultipleServersAsync<TIn, TOut>(
|
||||
string method,
|
||||
string contentType,
|
||||
|
|
Загрузка…
Ссылка в новой задаче