Skip to content

Commit 5eb9d0c

Browse files
Fix find all references calls to Roslyn (#10807)
Fixes integration test failures in Find All References. Roslyns LSP types got much more spec compliant in dotnet/roslyn#73911 and we were never sending the `Context` property in our request, so deserialization failed on their end.
2 parents f35b6c6 + ec671db commit 5eb9d0c

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT license. See License.txt in the project root for license information.
3+
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using Microsoft.CodeAnalysis.Razor.Protocol;
7+
using Microsoft.VisualStudio.LanguageServer.Protocol;
8+
using StreamJsonRpc;
9+
10+
namespace Microsoft.VisualStudio.Razor.LanguageClient.Endpoints;
11+
12+
internal partial class RazorCustomMessageTarget
13+
{
14+
[JsonRpcMethod(CustomMessageNames.RazorReferencesEndpointName, UseSingleObjectParameterDeserialization = true)]
15+
public async Task<VSInternalReferenceItem[]?> ReferencesAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
16+
{
17+
var delegationDetails = await GetProjectedRequestDetailsAsync(request, cancellationToken).ConfigureAwait(false);
18+
if (delegationDetails is null)
19+
{
20+
return default;
21+
}
22+
23+
var referenceParams = new ReferenceParams()
24+
{
25+
TextDocument = new VSTextDocumentIdentifier()
26+
{
27+
Uri = delegationDetails.Value.ProjectedUri,
28+
ProjectContext = null,
29+
},
30+
Position = request.ProjectedPosition,
31+
Context = new ReferenceContext(),
32+
};
33+
34+
var response = await _requestInvoker.ReinvokeRequestOnServerAsync<ReferenceParams, VSInternalReferenceItem[]?>(
35+
delegationDetails.Value.TextBuffer,
36+
Methods.TextDocumentReferencesName,
37+
delegationDetails.Value.LanguageServerName,
38+
referenceParams,
39+
cancellationToken).ConfigureAwait(false);
40+
41+
if (response is null)
42+
{
43+
return default;
44+
}
45+
46+
return response.Response;
47+
}
48+
}

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Endpoints/RazorCustomMessageTarget_TextDocumentPosition.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ internal partial class RazorCustomMessageTarget
2929
public Task<SumType<Location[], VSInternalReferenceItem[]>> ImplementationAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
3030
=> DelegateTextDocumentPositionAndProjectContextAsync<SumType<Location[], VSInternalReferenceItem[]>>(request, Methods.TextDocumentImplementationName, cancellationToken);
3131

32-
[JsonRpcMethod(CustomMessageNames.RazorReferencesEndpointName, UseSingleObjectParameterDeserialization = true)]
33-
public Task<VSInternalReferenceItem[]?> ReferencesAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
34-
=> DelegateTextDocumentPositionAndProjectContextAsync<VSInternalReferenceItem[]>(request, Methods.TextDocumentReferencesName, cancellationToken);
35-
3632
[JsonRpcMethod(CustomMessageNames.RazorSignatureHelpEndpointName, UseSingleObjectParameterDeserialization = true)]
3733
public Task<SignatureHelp?> SignatureHelpAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
3834
=> DelegateTextDocumentPositionAndProjectContextAsync<SignatureHelp>(request, Methods.TextDocumentSignatureHelpName, cancellationToken);

0 commit comments

Comments
 (0)