Exemplo n.º 1
0
        private AnalysisResult GetAnalysisResult([NotNull] AnalyzerTestContext context, [NotNull][ItemNotNull] string[] messages)
        {
            DocumentWithSpans documentWithSpans = DocumentFactory.GetDocumentWithSpansFromMarkup(context);

            IList <Diagnostic>        diagnostics = GetSortedAnalyzerDiagnostics(context, documentWithSpans);
            ImmutableArray <TextSpan> spans       = documentWithSpans.TextSpans.OrderBy(s => s).ToImmutableArray();

            return(new AnalysisResult(diagnostics, spans, messages));
        }
Exemplo n.º 2
0
        private IList <Diagnostic> GetSortedAnalyzerDiagnostics([NotNull] AnalyzerTestContext context,
                                                                [NotNull] DocumentWithSpans documentWithSpans)
        {
            IEnumerable <Diagnostic> diagnostics = EnumerateDiagnosticsForDocument(documentWithSpans.Document,
                                                                                   context.ValidationMode, context.DiagnosticsCaptureMode, context.Options).Where(d => d.Id == DiagnosticId);

            if (context.DiagnosticsCaptureMode == DiagnosticsCaptureMode.RequireInSourceTree)
            {
                diagnostics = diagnostics.OrderBy(d => d.Location.SourceSpan);
            }

            return(diagnostics.ToImmutableArray());
        }