diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index d31c2ebd..94a9edcc 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "fsharp-analyzers": { - "version": "0.26.0", + "version": "0.32.1", "commands": [ "fsharp-analyzers" ] diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 87dae709..82ea5002 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -34,4 +34,4 @@ jobs: uses: github/codeql-action/upload-sarif@v3 if: matrix.os == 'ubuntu-latest' with: - sarif_file: ./reports + sarif_file: ./analysis.sarif diff --git a/.gitignore b/.gitignore index dd9927a3..eb79946e 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,4 @@ tests/FSharp.Literate.Tests/output2/ tests/FSharp.Literate.Tests/previous-next-output/ # Analyzer -reports/ \ No newline at end of file +analysis.sarif \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index 481969f4..0f6a9d08 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -26,8 +26,7 @@ - - - + + \ No newline at end of file diff --git a/Directory.Solution.targets b/Directory.Solution.targets index 33bbc1dd..c6cc36c5 100644 --- a/Directory.Solution.targets +++ b/Directory.Solution.targets @@ -1,9 +1,26 @@ - - - + + - - - - \ No newline at end of file + + + + + + + $(SolutionDir) + --analyzers-path "$(PkgG-Research_FSharp_Analyzers)/analyzers/dotnet/fs" + $(FSharpAnalyzersOtherFlags) --analyzers-path "$(PkgIonide_Analyzers)/analyzers/dotnet/fs" + $(FSharpAnalyzersOtherFlags) --exclude-analyzers PartialAppAnalyzer ReturnStructPartialActivePatternAnalyzer -c Release + $(FSharpAnalyzersOtherFlags) --code-root $(CodeRoot) + $(FSharpAnalyzersOtherFlags) --report "$(CodeRoot)/analysis.sarif" + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 4839b530..108bfc06 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,10 +1,6 @@ - - all - build - all analyzers diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets deleted file mode 100644 index dbe79b39..00000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,8 +0,0 @@ - - - --analyzers-path "$(PkgG-Research_FSharp_Analyzers)/analyzers/dotnet/fs" - $(FSharpAnalyzersOtherFlags) --analyzers-path "$(PkgIonide_Analyzers)/analyzers/dotnet/fs" - $(FSharpAnalyzersOtherFlags) --exclude-analyzers PartialAppAnalyzer -c Release - $(FSharpAnalyzersOtherFlags) --code-root ../.. --report "../../reports/$(MSBuildProjectName)-$(TargetFramework).sarif" - - \ No newline at end of file diff --git a/src/FSharp.Formatting.ApiDocs/Categorise.fs b/src/FSharp.Formatting.ApiDocs/Categorise.fs index 40202f73..d107d193 100644 --- a/src/FSharp.Formatting.ApiDocs/Categorise.fs +++ b/src/FSharp.Formatting.ApiDocs/Categorise.fs @@ -53,28 +53,32 @@ let entities (nsIndex: int, ns: ApiDocNamespace, suppress) = // TODO: use to do these, or work out if there's a better way if suppress then categoryEntities - - // Remove FSharp.Data.UnitSystems.SI from the list-of-namespaces - // display - it's just so rarely used, has long names and dominates the docs. - // - // See https://github.com/fsharp/fsharp-core-docs/issues/57, we may rethink this - |> List.filter (fun e -> - (e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols")) - |> List.filter (fun e -> - (e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitNames")) - // Don't show 'AnonymousObject' in list-of-namespaces navigation |> List.filter (fun e -> + // Remove FSharp.Data.UnitSystems.SI from the list-of-namespaces + // display - it's just so rarely used, has long names and dominates the docs. + // + // See https://github.com/fsharp/fsharp-core-docs/issues/57, we may rethink this + (e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols") + && (e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitNames") + + && + + // Don't show 'AnonymousObject' in list-of-namespaces navigation not ( e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.RuntimeHelpers" && e.Symbol.DisplayName = "AnonymousObject" - )) - // Don't show 'FSharp.Linq.QueryRunExtensions' in list-of-namespaces navigation - |> List.filter (fun e -> + ) + + && + + // Don't show 'FSharp.Linq.QueryRunExtensions' in list-of-namespaces navigation not ( e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.QueryRunExtensions" && e.Symbol.DisplayName = "LowPriority" - )) - |> List.filter (fun e -> + ) + + && + not ( e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.QueryRunExtensions" && e.Symbol.DisplayName = "HighPriority" diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index d7cba720..c1c7272f 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -870,7 +870,7 @@ type internal CrossReferenceResolver(root, collectionName, qualify, extensions) let tryGetTypeFromMemberName (memberName: string) = let sub = removeParen memberName - let lastPeriod = sub.LastIndexOf(".") + let lastPeriod = sub.LastIndexOf('.') if lastPeriod > 0 then Some(memberName.Substring(0, lastPeriod)) @@ -879,7 +879,7 @@ type internal CrossReferenceResolver(root, collectionName, qualify, extensions) let tryGetShortMemberNameFromMemberName (memberName: string) = let sub = removeParen memberName - let lastPeriod = sub.LastIndexOf(".") + let lastPeriod = sub.LastIndexOf('.') if lastPeriod > 0 then Some(memberName.Substring(lastPeriod + 1)) diff --git a/src/FSharp.Formatting.Common/YaafFSharpScripting.fs b/src/FSharp.Formatting.Common/YaafFSharpScripting.fs index 6e32a331..bc8178be 100644 --- a/src/FSharp.Formatting.Common/YaafFSharpScripting.fs +++ b/src/FSharp.Formatting.Common/YaafFSharpScripting.fs @@ -282,14 +282,18 @@ module internal CompilerServiceExtensions = |> Seq.filter (fun file -> let fileName = Path.GetFullPath file |> Path.GetFileName - dllFiles - |> List.exists (fun (dllFile: string) -> Path.GetFileName dllFile =? fileName) - |> not) - |> Seq.filter (fun file -> - if Path.GetFileName file =? "FSharp.Core.dll" then - FSharpAssemblyHelper.tryCheckFsCore file |> Option.isSome - else - true) + let dllNotAlreadyReferenced = + dllFiles + |> List.exists (fun (dllFile: string) -> Path.GetFileName dllFile =? fileName) + |> not + + let checkFSharpCore = + if Path.GetFileName file =? "FSharp.Core.dll" then + FSharpAssemblyHelper.tryCheckFsCore file |> Option.isSome + else + true + + dllNotAlreadyReferenced && checkFSharpCore) |> Seq.toList // See https://github.com/tpetricek/FSharp.Formatting/commit/5d14f45cd7e70c2164a7448ea50a6b9995166489 @@ -350,7 +354,6 @@ type internal FsiEvaluationException (Log.formatArgs args) (base.ToString()) - /// Exception for invalid expression types type internal FsiExpressionTypeException = val private value: obj option diff --git a/src/FSharp.Formatting.Literate/ParseScript.fs b/src/FSharp.Formatting.Literate/ParseScript.fs index e1136dd7..8873edd4 100644 --- a/src/FSharp.Formatting.Literate/ParseScript.fs +++ b/src/FSharp.Formatting.Literate/ParseScript.fs @@ -62,7 +62,7 @@ module internal CodeBlockUtils = let rec private collectComment (comment: string) lines = seq { let findCommentEnd (comment: string) = - let cend = comment.LastIndexOf("*)") + let cend = comment.LastIndexOf("*)", StringComparison.OrdinalIgnoreCase) if cend = -1 then failwith "A (* comment was not closed"