private async Task <DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> > AnalyzeOutOfProcAsync(
                RemoteHostClient client, CompilationWithAnalyzers analyzerDriver, Project project, bool forcedAnalysis, CancellationToken cancellationToken)
            {
                var solution = project.Solution;

                using var pooledObject = SharedPools.Default <Dictionary <string, DiagnosticAnalyzer> >().GetPooledObject();
                var analyzerMap = pooledObject.Object;

                analyzerMap.AppendAnalyzerMap(analyzerDriver.Analyzers.Where(a => forcedAnalysis || !a.IsOpenFileOnly(solution.Options)));
                if (analyzerMap.Count == 0)
                {
                    return(DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> .Empty);
                }

                var argument = new DiagnosticArguments(
                    forcedAnalysis, analyzerDriver.AnalysisOptions.ReportSuppressedDiagnostics, analyzerDriver.AnalysisOptions.LogAnalyzerExecutionTime,
                    project.Id, analyzerMap.Keys.ToArray());

                var result = await client.TryRunRemoteAsync(
                    WellKnownServiceHubServices.CodeAnalysisService,
                    nameof(IRemoteDiagnosticAnalyzerService.CalculateDiagnosticsAsync),
                    solution,
                    new object[] { argument },
                    callbackTarget : null,
                    (s, c) => ReadCompilerAnalysisResultAsync(s, analyzerMap, project, c),
                    cancellationToken).ConfigureAwait(false);

                return(result.HasValue ? result.Value : DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> .Empty);
            }
Пример #2
0
 public Task <Optional <T> > TryRunRemoteAsync <T>(string targetName, Solution?solution, IReadOnlyList <object?> arguments, CancellationToken cancellationToken)
 => _client.TryRunRemoteAsync <T>(WellKnownServiceHubService.Razor, targetName, solution, arguments, callbackTarget: null, cancellationToken);