/// <summary> /// Calculate dignostics. this works differently than other ones such as todo comments or designer attribute scanner /// since in proc and out of proc runs quite differently due to concurrency and due to possible amount of data /// that needs to pass through between processes /// </summary> public Task CalculateDiagnosticsAsync(DiagnosticArguments arguments, string pipeName, CancellationToken cancellationToken) { return(RunServiceAsync(async() => { // if this analysis is explicitly asked by user, boost priority of this request using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_CalculateDiagnosticsAsync, arguments.ProjectId.DebugName, cancellationToken)) using (arguments.ForcedAnalysis ? UserOperationBooster.Boost() : default) { // entry point for diagnostic service var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false); var projectId = arguments.ProjectId; var analyzers = RoslynServices.AssetService.GetGlobalAssetsOfType <AnalyzerReference>(cancellationToken); var result = await new DiagnosticComputer(solution.GetProject(projectId)).GetDiagnosticsAsync( analyzers, arguments.AnalyzerIds, arguments.ReportSuppressedDiagnostics, arguments.LogAnalyzerExecutionTime, cancellationToken).ConfigureAwait(false); await RemoteEndPoint.WriteDataToNamedPipeAsync(pipeName, result, (writer, data, cancellationToken) => { var(diagnostics, telemetry, exceptions) = DiagnosticResultSerializer.WriteDiagnosticAnalysisResults(writer, data, cancellationToken); // save log for debugging Log(TraceEventType.Information, $"diagnostics: {diagnostics}, telemetry: {telemetry}, exceptions: {exceptions}"); return Task.CompletedTask; }, cancellationToken).ConfigureAwait(false); } }, cancellationToken)); }
/// <summary> /// Calculate dignostics. this works differently than other ones such as todo comments or designer attribute scanner /// since in proc and out of proc runs quite differently due to concurrency and due to possible amount of data /// that needs to pass through between processes /// </summary> public Task CalculateDiagnosticsAsync(PinnedSolutionInfo solutionInfo, DiagnosticArguments arguments, string pipeName, CancellationToken cancellationToken) { return(RunServiceAsync(async() => { using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_CalculateDiagnosticsAsync, arguments.ProjectId.DebugName, cancellationToken)) using (arguments.IsHighPriority ? UserOperationBooster.Boost() : default) { var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false); var documentId = arguments.DocumentId; var projectId = arguments.ProjectId; var project = solution.GetProject(projectId); var documentSpan = arguments.DocumentSpan; var documentAnalysisKind = arguments.DocumentAnalysisKind; var diagnosticComputer = new DiagnosticComputer(documentId, project, documentSpan, documentAnalysisKind, _analyzerInfoCache); var result = await diagnosticComputer.GetDiagnosticsAsync( arguments.AnalyzerIds, reportSuppressedDiagnostics: arguments.ReportSuppressedDiagnostics, logPerformanceInfo: arguments.LogPerformanceInfo, getTelemetryInfo: arguments.GetTelemetryInfo, cancellationToken).ConfigureAwait(false); await RemoteEndPoint.WriteDataToNamedPipeAsync(pipeName, (result, documentAnalysisKind), (writer, data, cancellationToken) => { var(diagnostics, telemetry) = DiagnosticResultSerializer.WriteDiagnosticAnalysisResults(writer, data.documentAnalysisKind, data.result, cancellationToken); // save log for debugging Log(TraceEventType.Information, $"diagnostics: {diagnostics}, telemetry: {telemetry}"); return Task.CompletedTask; }, cancellationToken).ConfigureAwait(false); } }, cancellationToken)); }