Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@

* Added warning FS3884 when a function or delegate value is used as an interpolated string argument. ([PR #19289](https://github.com/dotnet/fsharp/pull/19289))
* Symbols: add ObsoleteDiagnosticInfo ([PR #19359](https://github.com/dotnet/fsharp/pull/19359))
* FCS: add FSharpCheckFileResults.HasErrors ([PR #19892](https://github.com/dotnet/fsharp/pull/19892))
* Add `#version;;` directive to F# Interactive to display version and environment information. ([Issue #13307](https://github.com/dotnet/fsharp/issues/13307), [PR #19332](https://github.com/dotnet/fsharp/pull/19332))
* Debug: rework for expressions stepping ([PR #19894](https://github.com/dotnet/fsharp/pull/19894))

Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.VisualStudio/18.vNext.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
### Changed

* Rename "inline hints" to "inlay hints" in VS options for consistency with industry terminology. ([PR #19318](https://github.com/dotnet/fsharp/pull/19318))
* Unused analyzers: disable in VS when file has errors ([PR #19892](https://github.com/dotnet/fsharp/pull/19892))
3 changes: 3 additions & 0 deletions src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3411,6 +3411,9 @@ type FSharpCheckFileResults

member _.Diagnostics = errors

member _.HasErrors =
errors |> Array.exists (fun d -> d.Severity = FSharpDiagnosticSeverity.Error)

member _.HasFullTypeCheckInfo = details.IsSome

member _.TryGetCurrentTcImports() =
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/Service/FSharpCheckerResults.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ type public FSharpCheckFileResults =
/// The errors returned by parsing a source file.
member Diagnostics: FSharpDiagnostic[]

member HasErrors: bool

/// Get a view of the contents of the assembly up to and including the file just checked
member PartialAssemblySignature: FSharpAssemblySignature

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2085,8 +2085,10 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckFileAnswer: Int32 GetHashCode(System.Col
FSharp.Compiler.CodeAnalysis.FSharpCheckFileAnswer: Int32 Tag
FSharp.Compiler.CodeAnalysis.FSharpCheckFileAnswer: Int32 get_Tag()
FSharp.Compiler.CodeAnalysis.FSharpCheckFileAnswer: System.String ToString()
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Boolean HasErrors
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Boolean HasFullTypeCheckInfo
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Boolean IsRelativeNameResolvableFromSymbol(FSharp.Compiler.Text.Position, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Symbols.FSharpSymbol)
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Boolean get_HasErrors()
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: Boolean get_HasFullTypeCheckInfo()
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: FSharp.Compiler.CodeAnalysis.FSharpProjectContext ProjectContext
FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults: FSharp.Compiler.CodeAnalysis.FSharpProjectContext get_ProjectContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ type internal UnusedDeclarationsAnalyzer [<ImportingConstructor>] () =

let! unusedRanges = UnusedDeclarations.getUnusedDeclarations (checkResults, (isScriptFile document.FilePath))

let! sourceText = document.GetTextAsync()

return
unusedRanges
|> Seq.map (fun m -> Diagnostic.Create(descriptor, RoslynHelpers.RangeToLocation(m, sourceText, document.FilePath)))
|> Seq.toImmutableArray
if checkResults.HasErrors then
return ImmutableArray.Empty
else
let! sourceText = document.GetTextAsync()

return
unusedRanges
|> Seq.map (fun m ->
Diagnostic.Create(descriptor, RoslynHelpers.RangeToLocation(m, sourceText, document.FilePath)))
|> Seq.toImmutableArray
}
|> CancellableTask.start cancellationToken
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ type internal UnusedOpensDiagnosticAnalyzer [<ImportingConstructor>] () =

let! _, checkResults = document.GetFSharpParseAndCheckResultsAsync(nameof UnusedOpensDiagnosticAnalyzer)

let! unusedOpens =
UnusedOpens.getUnusedOpens (checkResults, (fun lineNumber -> sourceText.Lines[Line.toZ lineNumber].ToString()))
if checkResults.HasErrors then
return ValueNone
else
let! unusedOpens =
UnusedOpens.getUnusedOpens (checkResults, (fun lineNumber -> sourceText.Lines[Line.toZ lineNumber].ToString()))

return (ValueSome unusedOpens)
return (ValueSome unusedOpens)
}

interface IFSharpUnusedOpensDiagnosticAnalyzer with
Expand Down
Loading