private async Task <DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> > AnalyzeOutOfProcAsync( RemoteHostClient client, CompilationWithAnalyzers analyzerDriver, Project project, CancellationToken cancellationToken) { var solution = project.Solution; var snapshotService = solution.Workspace.Services.GetService <ISolutionSynchronizationService>(); // TODO: this should be moved out var analyzerMap = CreateAnalyzerMap(analyzerDriver.Analyzers); if (analyzerMap.Count == 0) { return(DiagnosticAnalysisResultMap.Create(ImmutableDictionary <DiagnosticAnalyzer, DiagnosticAnalysisResult> .Empty, ImmutableDictionary <DiagnosticAnalyzer, AnalyzerTelemetryInfo> .Empty)); } var optionAsset = GetOptionsAsset(solution, project.Language, cancellationToken); var hostChecksums = GetHostAnalyzerReferences(snapshotService, project.Language, _analyzerServiceOpt?.GetHostAnalyzerReferences(), cancellationToken); var argument = new DiagnosticArguments( analyzerDriver.AnalysisOptions.ReportSuppressedDiagnostics, analyzerDriver.AnalysisOptions.LogAnalyzerExecutionTime, project.Id, optionAsset.Checksum, hostChecksums, analyzerMap.Keys.ToArray()); using (var session = await client.TryCreateCodeAnalysisServiceSessionAsync(solution, cancellationToken).ConfigureAwait(false)) { if (session == null) { // session is not available return(DiagnosticAnalysisResultMap.Create(ImmutableDictionary <DiagnosticAnalyzer, DiagnosticAnalysisResult> .Empty, ImmutableDictionary <DiagnosticAnalyzer, AnalyzerTelemetryInfo> .Empty)); } session.AddAdditionalAssets(optionAsset); var result = await session.InvokeAsync( WellKnownServiceHubServices.CodeAnalysisService_CalculateDiagnosticsAsync, new object[] { argument }, (s, c) => GetCompilerAnalysisResultAsync(s, analyzerMap, project, c)).ConfigureAwait(false); ReportAnalyzerExceptions(project, result.Exceptions); return(result); } }