diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/DiagnosticVerifier.Helper.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/DiagnosticVerifier.Helper.cs index 88fbde558..c776264b7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/DiagnosticVerifier.Helper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/DiagnosticVerifier.Helper.cs @@ -71,8 +71,10 @@ protected static async Task> GetSortedDiagnosticsFrom { var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); var compilationWithAnalyzers = compilation.WithAnalyzers(ImmutableArray.Create(analyzer), null, cancellationToken); + var compilerDiagnostics = compilation.GetDiagnostics(cancellationToken); + var compilerErrors = compilerDiagnostics.Where(i => i.Severity == DiagnosticSeverity.Error); var diags = await compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync().ConfigureAwait(false); - foreach (var diag in diags) + foreach (var diag in diags.Concat(compilerErrors)) { if (diag.Location == Location.None || diag.Location.IsInMetadata) {