提交 af2771b7 编写于 作者: P Paul Vick

Fix serialization

上级 2869b7ef
......@@ -8,6 +8,7 @@
using Microsoft.CodeAnalysis.CodeLens;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Remote;
using Microsoft.CodeAnalysis.Remote.Diagnostics;
using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions;
using Microsoft.VisualStudio.LanguageServices.Remote;
......@@ -29,7 +30,7 @@ internal sealed class RemoteCodeLensReferencesService : ICodeLensReferencesServi
// TODO: send telemetry on session
using (var session = await remoteHostClient.CreateCodeAnalysisServiceSessionAsync(solution, cancellationToken).ConfigureAwait(false))
{
return await session.InvokeAsync<ReferenceCount>(WellKnownServiceHubServices.CodeAnalysisService_GetReferenceCountAsync, documentId, syntaxNode.Span, maxSearchResults).ConfigureAwait(false);
return await session.InvokeAsync<ReferenceCount>(WellKnownServiceHubServices.CodeAnalysisService_GetReferenceCountAsync, new CodeLensArguments(documentId), syntaxNode.Span, maxSearchResults).ConfigureAwait(false);
}
}
......@@ -46,7 +47,7 @@ internal sealed class RemoteCodeLensReferencesService : ICodeLensReferencesServi
// TODO: send telemetry on session
using (var session = await remoteHostClient.CreateCodeAnalysisServiceSessionAsync(solution, cancellationToken).ConfigureAwait(false))
{
return await session.InvokeAsync<IEnumerable<ReferenceLocationDescriptor>>(WellKnownServiceHubServices.CodeAnalysisService_FindReferenceLocationsAsync, documentId, syntaxNode.Span).ConfigureAwait(false);
return await session.InvokeAsync<IEnumerable<ReferenceLocationDescriptor>>(WellKnownServiceHubServices.CodeAnalysisService_FindReferenceLocationsAsync, new CodeLensArguments(documentId), syntaxNode.Span).ConfigureAwait(false);
}
}
......@@ -63,7 +64,7 @@ internal sealed class RemoteCodeLensReferencesService : ICodeLensReferencesServi
// TODO: send telemetry on session
using (var session = await remoteHostClient.CreateCodeAnalysisServiceSessionAsync(solution, cancellationToken).ConfigureAwait(false))
{
return await session.InvokeAsync<IEnumerable<ReferenceMethodDescriptor>>(WellKnownServiceHubServices.CodeAnalysisService_FindReferenceMethodsAsync, documentId, syntaxNode.Span).ConfigureAwait(false);
return await session.InvokeAsync<IEnumerable<ReferenceMethodDescriptor>>(WellKnownServiceHubServices.CodeAnalysisService_FindReferenceMethodsAsync, new CodeLensArguments(documentId), syntaxNode.Span).ConfigureAwait(false);
}
}
......@@ -80,7 +81,7 @@ internal sealed class RemoteCodeLensReferencesService : ICodeLensReferencesServi
// TODO: send telemetry on session
using (var session = await remoteHostClient.CreateCodeAnalysisServiceSessionAsync(solution, cancellationToken).ConfigureAwait(false))
{
return await session.InvokeAsync<string>(WellKnownServiceHubServices.CodeAnalysisService_GetFullyQualifiedName, documentId, syntaxNode.Span).ConfigureAwait(false);
return await session.InvokeAsync<string>(WellKnownServiceHubServices.CodeAnalysisService_GetFullyQualifiedName, new CodeLensArguments(documentId), syntaxNode.Span).ConfigureAwait(false);
}
}
}
......
......@@ -74,6 +74,9 @@
<PublicAPI Include="PublicAPI.Unshipped.txt" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\Workspaces\Remote\ServiceHub\CodeLens\CodeLensArguments.cs">
<Link>CodeLens\CodeLensArguments.cs</Link>
</Compile>
<Compile Include="..\..\..\Workspaces\Remote\ServiceHub\Diagnostics\DiagnosticArguments.cs">
<Link>Diagnostics\DiagnosticArguments.cs</Link>
</Compile>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.Execution;
namespace Microsoft.CodeAnalysis.Remote.Diagnostics
{
/// <summary>
/// helper type to package diagnostic arguments to pass around between remote hosts
/// </summary>
internal class CodeLensArguments
{
public Guid ProjectIdGuid;
public string ProjectIdDebugName;
public Guid DocumentIdGuid;
public string DocumentIdDebugName;
public CodeLensArguments()
{
}
public CodeLensArguments(DocumentId documentId)
{
ProjectIdGuid = documentId.ProjectId.Id;
ProjectIdDebugName = documentId.ProjectId.DebugName;
DocumentIdGuid = documentId.Id;
DocumentIdDebugName = documentId.DebugName;
}
public DocumentId GetDocumentId()
=>
DocumentId.CreateFromSerialized(ProjectId.CreateFromSerialized(ProjectIdGuid, ProjectIdDebugName),
DocumentIdGuid, DocumentIdDebugName);
}
}
\ No newline at end of file
......@@ -49,6 +49,7 @@
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
<Compile Include="CodeLens\CodeLensArguments.cs" />
<Compile Include="Services\CodeAnalysisService_CodeLens.cs" />
<Compile Include="Services\SnapshotService.JsonRpcAssetSource.cs" />
<PublicAPI Include="PublicAPI.Shipped.txt" />
......
......@@ -7,16 +7,18 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Execution;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Remote.Diagnostics;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Remote
{
internal partial class CodeAnalysisService
{
public async Task<ReferenceCount> GetReferenceCountAsync(DocumentId documentId, TextSpan textSpan, int maxResultCount, byte[] solutionChecksum)
public async Task<ReferenceCount> GetReferenceCountAsync(CodeLensArguments arguments, TextSpan textSpan, int maxResultCount, byte[] solutionChecksum)
{
try
{
var documentId = arguments.GetDocumentId();
using (Internal.Log.Logger.LogBlock(FunctionId.CodeAnalysisService_GetReferenceCountAsync, documentId.ProjectId.DebugName, CancellationToken))
{
var solution = await RoslynServices.SolutionService.GetSolutionAsync(new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);
......@@ -41,10 +43,12 @@ public async Task<ReferenceCount> GetReferenceCountAsync(DocumentId documentId,
return null;
}
public async Task<IEnumerable<ReferenceLocationDescriptor>> FindReferenceLocationsAsync(DocumentId documentId, TextSpan textSpan, byte[] solutionChecksum)
public async Task<IEnumerable<ReferenceLocationDescriptor>> FindReferenceLocationsAsync(CodeLensArguments arguments, TextSpan textSpan, byte[] solutionChecksum)
{
try
{
var documentId = arguments.GetDocumentId();
using (Internal.Log.Logger.LogBlock(FunctionId.CodeAnalysisService_FindReferenceLocationsAsync, documentId.ProjectId.DebugName, CancellationToken))
{
var solution = await RoslynServices.SolutionService.GetSolutionAsync(new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);
......@@ -69,10 +73,12 @@ public async Task<IEnumerable<ReferenceLocationDescriptor>> FindReferenceLocatio
return null;
}
public async Task<IEnumerable<ReferenceMethodDescriptor>> FindReferenceMethodsAsync(DocumentId documentId, TextSpan textSpan, byte[] solutionChecksum)
public async Task<IEnumerable<ReferenceMethodDescriptor>> FindReferenceMethodsAsync(CodeLensArguments arguments, TextSpan textSpan, byte[] solutionChecksum)
{
try
{
var documentId = arguments.GetDocumentId();
using (Internal.Log.Logger.LogBlock(FunctionId.CodeAnalysisService_FindReferenceMethodsAsync, documentId.ProjectId.DebugName, CancellationToken))
{
var solution = await RoslynServices.SolutionService.GetSolutionAsync(new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);
......@@ -97,10 +103,12 @@ public async Task<IEnumerable<ReferenceMethodDescriptor>> FindReferenceMethodsAs
return null;
}
public async Task<string> GetFullyQualifiedName(DocumentId documentId, TextSpan textSpan, byte[] solutionChecksum)
public async Task<string> GetFullyQualifiedName(CodeLensArguments arguments, TextSpan textSpan, byte[] solutionChecksum)
{
try
{
var documentId = arguments.GetDocumentId();
using (Internal.Log.Logger.LogBlock(FunctionId.CodeAnalysisService_GetFullyQualifiedName, documentId.ProjectId.DebugName, CancellationToken))
{
var solution = await RoslynServices.SolutionService.GetSolutionAsync(new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册