diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs index c3fd80b8d8b..d7667baf2c9 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs @@ -81,23 +81,24 @@ type internal FSharpDocumentDiagnosticAnalyzer() = } let results = - (errors |> Seq.choose(fun error -> - if error.StartLineAlternate = 0 || error.EndLineAlternate = 0 then - // F# error line numbers are one-based. Compiler returns 0 for global errors (reported by ProjectDiagnosticAnalyzer) - None - else - // Roslyn line numbers are zero-based - let linePositionSpan = LinePositionSpan(LinePosition(error.StartLineAlternate - 1, error.StartColumn),LinePosition(error.EndLineAlternate - 1, error.EndColumn)) - let textSpan = sourceText.Lines.GetTextSpan(linePositionSpan) - - // F# compiler report errors at end of file if parsing fails. It should be corrected to match Roslyn boundaries - let correctedTextSpan = - if textSpan.End < sourceText.Length then textSpan - else TextSpan.FromBounds(max 0 (sourceText.Length - 1), sourceText.Length) - - let location = Location.Create(filePath, correctedTextSpan , linePositionSpan) - Some(CommonRoslynHelpers.ConvertError(error, location))) - ).ToImmutableArray() + (HashSet(errors, errorInfoEqualityComparer) + |> Seq.choose(fun error -> + if error.StartLineAlternate = 0 || error.EndLineAlternate = 0 then + // F# error line numbers are one-based. Compiler returns 0 for global errors (reported by ProjectDiagnosticAnalyzer) + None + else + // Roslyn line numbers are zero-based + let linePositionSpan = LinePositionSpan(LinePosition(error.StartLineAlternate - 1, error.StartColumn), LinePosition(error.EndLineAlternate - 1, error.EndColumn)) + let textSpan = sourceText.Lines.GetTextSpan(linePositionSpan) + + // F# compiler report errors at end of file if parsing fails. It should be corrected to match Roslyn boundaries + let correctedTextSpan = + if textSpan.End < sourceText.Length then textSpan + else TextSpan.FromBounds(max 0 (sourceText.Length - 1), sourceText.Length) + + let location = Location.Create(filePath, correctedTextSpan , linePositionSpan) + Some(CommonRoslynHelpers.ConvertError(error, location))) + ).ToImmutableArray() return results }