Skip to content

Commit

Permalink
Fixed that DiagnosticVerifier.Helper sorts result Diagnostic objects …
Browse files Browse the repository at this point in the history
…only by SourceSpan, meaning that when multiple source files are involved, VerifyDiagnostic and VerifyCodeFix can report false negatives, since they both rely on Diagnostic and DiagnosticResult objects being sorted the same, in order to successfully check for differences.
  • Loading branch information
JakenVeina committed Feb 4, 2020
1 parent 0680705 commit 01fc349
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
Expand Down Expand Up @@ -92,7 +92,10 @@ protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyz
/// <returns>An IEnumerable containing the Diagnostics in order of Location</returns>
private static Diagnostic[] SortDiagnostics(IEnumerable<Diagnostic> diagnostics)
{
return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
return diagnostics
.OrderBy(d => d.Location.SourceTree.FilePath)
.ThenBy(d => d.Location.SourceSpan.Start)
.ToArray();
}

#endregion
Expand Down

0 comments on commit 01fc349

Please sign in to comment.