Exemplo n.º 1
0
        private async Task <IEnumerable <Diagnostic> > GetProjectDiagnosticsAsync(Project project, bool includeAllDocumentDiagnostics, ImmutableHashSet <string> diagnosticIds, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(project);

            var diagnostics = await _diagnosticService.GetProjectDiagnosticsForIdsAsync(project.Solution, project.Id, diagnosticIds, cancellationToken : cancellationToken).ConfigureAwait(false);

            Contract.ThrowIfFalse(diagnostics.All(d => d.DocumentId == null));
            var dxs = diagnostics.Select(d => d.ToDiagnostic(null));

            if (includeAllDocumentDiagnostics)
            {
                var list = new List <Diagnostic>();
                list.AddRange(dxs);

                foreach (var document in project.Documents)
                {
                    var docDiagnsotics = await GetDocumentDiagnosticsAsync(document, diagnosticIds, cancellationToken).ConfigureAwait(false);

                    list.AddRange(docDiagnsotics);
                }

                return(list);
            }
            else
            {
                return(dxs);
            }
        }
            public override async Task <IEnumerable <Diagnostic> > GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken)
            {
                // Get all no-location diagnostics for the project, doesn't include document diagnostics.
                var diagnostics = await _diagnosticService.GetProjectDiagnosticsForIdsAsync(project.Solution, project.Id, _diagnosticIds, _includeSuppressedDiagnostics, cancellationToken).ConfigureAwait(false);

                Contract.ThrowIfFalse(diagnostics.All(d => d.DocumentId == null));
                return(await diagnostics.ToDiagnosticsAsync(project, cancellationToken).ConfigureAwait(false));
            }
Exemplo n.º 3
0
        private async Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, bool includeAllDocumentDiagnostics, ImmutableHashSet<string> diagnosticIds, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(project);

            if (includeAllDocumentDiagnostics)
            {
                // Get all diagnostics for the entire project, including document diagnostics.
                var diagnostics = await _diagnosticService.GetDiagnosticsForIdsAsync(project.Solution, project.Id, diagnosticIds: diagnosticIds, cancellationToken: cancellationToken).ConfigureAwait(false);
                return await diagnostics.ToDiagnosticsAsync(project, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                // Get all no-location diagnostics for the project, doesn't include document diagnostics.
                var diagnostics = await _diagnosticService.GetProjectDiagnosticsForIdsAsync(project.Solution, project.Id, diagnosticIds, cancellationToken: cancellationToken).ConfigureAwait(false);
                Contract.ThrowIfFalse(diagnostics.All(d => d.DocumentId == null));
                return await diagnostics.ToDiagnosticsAsync(project, cancellationToken).ConfigureAwait(false);
            }
        }