@@ -81,23 +81,24 @@ type internal FSharpDocumentDiagnosticAnalyzer() =
8181}
8282
8383let results =
84- ( errors|> Seq.choose( fun error ->
85- if error.StartLineAlternate= 0 || error.EndLineAlternate= 0 then
86- // F# error line numbers are one-based. Compiler returns 0 for global errors (reported by ProjectDiagnosticAnalyzer)
87- None
88- else
89- // Roslyn line numbers are zero-based
90- let linePositionSpan = LinePositionSpan( LinePosition( error.StartLineAlternate- 1 , error.StartColumn), LinePosition( error.EndLineAlternate- 1 , error.EndColumn))
91- let textSpan = sourceText.Lines.GetTextSpan( linePositionSpan)
92-
93- // F# compiler report errors at end of file if parsing fails. It should be corrected to match Roslyn boundaries
94- let correctedTextSpan =
95- if textSpan.End< sourceText.Lengththen textSpan
96- else TextSpan.FromBounds( max0 ( sourceText.Length- 1 ), sourceText.Length)
97-
98- let location = Location.Create( filePath, correctedTextSpan, linePositionSpan)
99- Some( CommonRoslynHelpers.ConvertError( error, location)))
100- ) .ToImmutableArray()
84+ ( HashSet( errors, errorInfoEqualityComparer)
85+ |> Seq.choose( fun error ->
86+ if error.StartLineAlternate= 0 || error.EndLineAlternate= 0 then
87+ // F# error line numbers are one-based. Compiler returns 0 for global errors (reported by ProjectDiagnosticAnalyzer)
88+ None
89+ else
90+ // Roslyn line numbers are zero-based
91+ let linePositionSpan = LinePositionSpan( LinePosition( error.StartLineAlternate- 1 , error.StartColumn), LinePosition( error.EndLineAlternate- 1 , error.EndColumn))
92+ let textSpan = sourceText.Lines.GetTextSpan( linePositionSpan)
93+
94+ // F# compiler report errors at end of file if parsing fails. It should be corrected to match Roslyn boundaries
95+ let correctedTextSpan =
96+ if textSpan.End< sourceText.Lengththen textSpan
97+ else TextSpan.FromBounds( max0 ( sourceText.Length- 1 ), sourceText.Length)
98+
99+ let location = Location.Create( filePath, correctedTextSpan, linePositionSpan)
100+ Some( CommonRoslynHelpers.ConvertError( error, location)))
101+ ) .ToImmutableArray()
101102return results
102103}
103104