protected static void AnalyzeDocumentCore(IDiagnosticAnalyzer analyzer, Document document, Action <Diagnostic> addDiagnostic, TextSpan?span = null, bool continueOnError = false) { TextSpan spanToTest = span.HasValue ? span.Value : document.GetSyntaxRootAsync().Result.FullSpan; var semanticModel = document.GetSemanticModelAsync().Result; AnalyzerDriver.RunAnalyzers(semanticModel, spanToTest, ImmutableArray.Create(analyzer), addDiagnostic, continueOnError: continueOnError); }