Skip to content

Add codelens endpoints and services for cohosting #12078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions eng/Version.Details.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ This file should be imported by eng/Versions.props
<Project>
<PropertyGroup>
<!-- dotnet/roslyn dependencies -->
<MicrosoftCodeAnalysisAnalyzersPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisAnalyzersPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>
<MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>5.0.0-2.25380.11</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>5.0.0-2.25380.11</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>5.0.0-2.25380.11</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>5.0.0-2.25380.11</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftCodeAnalysisAnalyzersPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisAnalyzersPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisExternalAccessFSharpPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisExternalAccessRazorEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisExternalAccessRazorFeaturesPackageVersion>
<MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisLanguageServerProtocolPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>5.0.0-2.25406.1</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>5.0.0-2.25406.1</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>5.0.0-2.25406.1</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>5.0.0-2.25406.1</MicrosoftVisualStudioLanguageServicesPackageVersion>
<!-- dotnet/arcade dependencies -->
<MicrosoftDotNetArcadeSdkPackageVersion>9.0.0-beta.25255.5</MicrosoftDotNetArcadeSdkPackageVersion>
<!-- dotnet/aspnetcore dependencies -->
Expand Down
84 changes: 42 additions & 42 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,89 @@
<Dependencies>
<Source Uri="https://github.com/dotnet/dotnet" Mapping="razor" Sha="8b29a1682219da555ee27e4fdda55dc3884b316f" BarId="277635" />
<ProductDependencies>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.EditorFeatures" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor.EditorFeatures" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.LanguageServer.Protocol" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.LanguageServer.Protocol" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.FSharp" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.FSharp" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="5.0.0-2.25380.11">
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="5.0.0-2.25406.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>512fe5197056a877a86dff3054d8bd0028af13ed</Sha>
<Sha>5759a992418f0fd3e206cc6f369b6f33e873dfca</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
1 change: 1 addition & 0 deletions eng/targets/Services.props
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
<ServiceHubService Include="Microsoft.VisualStudio.Razor.DebugInfo" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteDebugInfoService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.WrapWithTag" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteWrapWithTagService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.SpanMapping" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteSpanMappingService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.CodeLens" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteCodeLensService+Factory" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;
using Microsoft.CodeAnalysis.Razor.Cohost;
using Microsoft.CodeAnalysis.Razor.Remote;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

#pragma warning disable RS0030 // Do not use banned APIs
[Shared]
[CohostEndpoint(Methods.TextDocumentCodeLensName)]
[Export(typeof(IDynamicRegistrationProvider))]
[ExportRazorStatelessLspService(typeof(CohostCodeLensEndpoint))]
[method: ImportingConstructor]
#pragma warning restore RS0030 // Do not use banned APIs
internal sealed class CohostCodeLensEndpoint(
IIncompatibleProjectService incompatibleProjectService,
IRemoteServiceInvoker remoteServiceInvoker)
: AbstractCohostDocumentEndpoint<CodeLensParams, LspCodeLens[]?>(incompatibleProjectService), IDynamicRegistrationProvider
{
private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker;

protected override bool MutatesSolutionState => false;
protected override bool RequiresLSPSolution => true;

public ImmutableArray<Registration> GetRegistrations(VSInternalClientCapabilities clientCapabilities, RazorCohostRequestContext requestContext)
{
if (clientCapabilities.TextDocument?.CodeLens?.DynamicRegistration is true)
{
return [new Registration()
{
Method = Methods.TextDocumentCodeLensName,
RegisterOptions = new CodeLensRegistrationOptions()
{
ResolveProvider = true
}
}];
}

return [];
}

protected override RazorTextDocumentIdentifier? GetRazorTextDocumentIdentifier(CodeLensParams request)
=> request.TextDocument.ToRazorTextDocumentIdentifier();

protected override async Task<LspCodeLens[]?> HandleRequestAsync(CodeLensParams request, TextDocument razorDocument, CancellationToken cancellationToken)
{
var result = await _remoteServiceInvoker.TryInvokeAsync<IRemoteCodeLensService, LspCodeLens[]?>(
razorDocument.Project.Solution,
(service, solutionInfo, cancellationToken) => service.GetCodeLensAsync(solutionInfo, razorDocument.Id, request.TextDocument, cancellationToken),
cancellationToken).ConfigureAwait(false);

return result;
}

internal TestAccessor GetTestAccessor() => new(this);

internal readonly struct TestAccessor(CohostCodeLensEndpoint instance)
{
public Task<LspCodeLens[]?> HandleRequestAsync(CodeLensParams request, TextDocument razorDocument, CancellationToken cancellationToken)
=> instance.HandleRequestAsync(request, razorDocument, cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;
using Microsoft.CodeAnalysis.Razor.Cohost;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces.CodeLens;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

#pragma warning disable RS0030 // Do not use banned APIs
[Shared]
[CohostEndpoint(Methods.CodeLensResolveName)]
[ExportRazorStatelessLspService(typeof(CohostResolveCodeLensEndpoint))]
[method: ImportingConstructor]
#pragma warning restore RS0030 // Do not use banned APIs
internal sealed class CohostResolveCodeLensEndpoint(
IIncompatibleProjectService incompatibleProjectService,
IRemoteServiceInvoker remoteServiceInvoker)
: AbstractCohostDocumentEndpoint<LspCodeLens, LspCodeLens>(incompatibleProjectService)
{
private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker;

protected override bool MutatesSolutionState => false;
protected override bool RequiresLSPSolution => true;

protected override RazorTextDocumentIdentifier? GetRazorTextDocumentIdentifier(LspCodeLens request)
=> RazorCodeLensResolveData.Unwrap(request).TextDocument.ToRazorTextDocumentIdentifier();

protected override async Task<LspCodeLens?> HandleRequestAsync(LspCodeLens request, TextDocument razorDocument, CancellationToken cancellationToken)
{
var result = await _remoteServiceInvoker.TryInvokeAsync<IRemoteCodeLensService, LspCodeLens?>(
razorDocument.Project.Solution,
(service, solutionInfo, cancellationToken) => service.ResolveCodeLensAsync(solutionInfo, razorDocument.Id, request, cancellationToken),
cancellationToken).ConfigureAwait(false);

return result;
}

internal TestAccessor GetTestAccessor() => new(this);

internal readonly struct TestAccessor(CohostResolveCodeLensEndpoint instance)
{
public RazorTextDocumentIdentifier? GetRazorTextDocumentIdentifier(LspCodeLens request)
=> instance.GetRazorTextDocumentIdentifier(request);

public Task<LspCodeLens?> HandleRequestAsync(LspCodeLens request, TextDocument razorDocument, CancellationToken cancellationToken)
=> instance.HandleRequestAsync(request, razorDocument, cancellationToken);
}
}
Loading