protected override Task <ImmutableArray <DiagnosticData> > GetDiagnosticsAsync( RequestContext context, Document document, Option2 <DiagnosticMode> diagnosticMode, CancellationToken cancellationToken) { // For open documents, directly use the IDiagnosticAnalyzerService. This will use the actual snapshots // we're passing in. If information is already cached for that snapshot, it will be returned. Otherwise, // it will be computed on demand. Because it is always accurate as per this snapshot, all spans are correct // and do not need to be adjusted. return(_analyzerService.GetDiagnosticsAsync(document.Project.Solution, documentId: document.Id, cancellationToken: cancellationToken)); }
private async Task <ImmutableArray <DiagnosticData> > GetAllDiagnosticsAsync(Func <Project, bool> shouldFixInProject, CancellationToken cancellationToken) { var builder = ImmutableArray.CreateBuilder <DiagnosticData>(); var solution = _workspace.CurrentSolution; foreach (var project in solution.Projects) { if (shouldFixInProject(project)) { var diagnostics = await _diagnosticService.GetDiagnosticsAsync(solution, project.Id, includeSuppressedDiagnostics : true, cancellationToken : cancellationToken).ConfigureAwait(false); builder.AddRange(diagnostics.Where(d => d.Severity != DiagnosticSeverity.Hidden)); } } return(builder.ToImmutable()); }