diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 09d170d52..c8f323af1 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "fantomas": { - "version": "5.0.0-alpha-007", + "version": "5.0.0-alpha-008", "commands": [ "fantomas" ] diff --git a/.fantomasignore b/.fantomasignore new file mode 100644 index 000000000..800a291f1 --- /dev/null +++ b/.fantomasignore @@ -0,0 +1,2 @@ +docs/*.fsx +paket-files/ diff --git a/docs/apidocs.fsx b/docs/apidocs.fsx index e571cf524..0ebbef309 100644 --- a/docs/apidocs.fsx +++ b/docs/apidocs.fsx @@ -16,11 +16,11 @@ index: 5 (*** condition: fsx ***) #if FSX #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // FSX (*** condition: ipynb ***) #if IPYNB #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // IPYNB (*** hide ***) let root = "C:\\" diff --git a/docs/codeformat.fsx b/docs/codeformat.fsx index 5c6561099..3c36b4dfb 100644 --- a/docs/codeformat.fsx +++ b/docs/codeformat.fsx @@ -15,11 +15,11 @@ index: 1 (*** condition: fsx ***) #if FSX #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // FSX (*** condition: ipynb ***) #if IPYNB #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // IPYNB (** [![Binder](img/badge-binder.svg)](https://mybinder.org/v2/gh/fsprojects/fsharp.formatting/gh-pages?filepath={{fsdocs-source-basename}}.ipynb)  diff --git a/docs/content.fsx b/docs/content.fsx index e7aa1740e..37e5ff6f0 100644 --- a/docs/content.fsx +++ b/docs/content.fsx @@ -15,11 +15,11 @@ index: 3 (*** condition: fsx ***) #if FSX #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // FSX (*** condition: ipynb ***) #if IPYNB #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // IPYNB (** diff --git a/docs/evaluation.fsx b/docs/evaluation.fsx index 4af3c82d5..99c603def 100644 --- a/docs/evaluation.fsx +++ b/docs/evaluation.fsx @@ -15,11 +15,11 @@ index: 6 (*** condition: fsx ***) #if FSX #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // FSX (*** condition: ipynb ***) #if IPYNB #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // IPYNB (** [![Binder](img/badge-binder.svg)](https://mybinder.org/v2/gh/fsprojects/fsharp.formatting/gh-pages?filepath={{fsdocs-source-basename}}.ipynb)  diff --git a/docs/literate.fsx b/docs/literate.fsx index c3d1d6137..ecbd7475e 100644 --- a/docs/literate.fsx +++ b/docs/literate.fsx @@ -15,11 +15,11 @@ index: 3 (*** condition: fsx ***) #if FSX #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // FSX (*** condition: ipynb ***) #if IPYNB #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // IPYNB (** diff --git a/docs/markdown.fsx b/docs/markdown.fsx index 989ef4003..58dc54c36 100644 --- a/docs/markdown.fsx +++ b/docs/markdown.fsx @@ -12,11 +12,11 @@ index: 2 (*** condition: fsx ***) #if FSX #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // FSX (*** condition: ipynb ***) #if IPYNB #r "nuget: FSharp.Formatting,{{fsdocs-package-version}}" -#endif +#endif // IPYNB (** diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index c727665b1..43c3ceb82 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -731,8 +731,8 @@ module internal CrossReferences = | "" -> try defaultArg (Option.map (sprintf "T:%s") typ.TryFullName) "" - with - | _ -> "" + with _ -> + "" | n -> n let getMemberXmlDocsSigPrefix (memb: FSharpMemberOrFunctionOrValue) = @@ -784,8 +784,7 @@ module internal CrossReferences = "" sprintf "%s%s%s" name typeArgs paramList - with - | exn -> + with exn -> printfn "Error while building fsdocs-member-name for %s because: %s" memb.FullName exn.Message Log.verbf "Full Exception details of previous message: %O" exn memb.CompiledName @@ -1603,8 +1602,8 @@ module internal SymbolReader = v.ApparentEnclosingEntity, formatTyconRefAsHtml ctx.UrlMap v.ApparentEnclosingEntity |> codeHtml ) - with - | _ -> None + with _ -> + None else None @@ -2387,8 +2386,8 @@ module internal SymbolReader = | Let "1000" (idx, _) -> (try int idx - with - | _ -> Int32.MaxValue) + with _ -> + Int32.MaxValue) let exclude = match cmds with @@ -2398,17 +2397,14 @@ module internal SymbolReader = try Some(f cat catindex exclude cmds comment, nsdocs) - with - | e -> + with e -> let name = try sym.FullName - with - | _ -> + with _ -> try sym.DisplayName - with - | _ -> + with _ -> let part = try let ass = sym.Assembly @@ -2416,8 +2412,8 @@ module internal SymbolReader = match ass.FileName with | Some file -> file | None -> ass.QualifiedName - with - | _ -> "unknown" + with _ -> + "unknown" sprintf "unknown, part of %s" part diff --git a/src/FSharp.Formatting.CodeFormat/Pervasive.fs b/src/FSharp.Formatting.CodeFormat/Pervasive.fs index e5297ef30..4b34676e6 100644 --- a/src/FSharp.Formatting.CodeFormat/Pervasive.fs +++ b/src/FSharp.Formatting.CodeFormat/Pervasive.fs @@ -157,8 +157,8 @@ type FSharpChecker with let! worker = Async.StartChild(parseAndCheckFile, 2000) let! result = worker return Ready result - with - | :? TimeoutException -> return StillRunning parseAndCheckFile + with :? TimeoutException -> + return StillRunning parseAndCheckFile } let bindParsedInput (results: (FSharpParseFileResults * FSharpCheckFileResults) option) = diff --git a/src/FSharp.Formatting.Common/Templating.fs b/src/FSharp.Formatting.Common/Templating.fs index 9d619f09a..cdd280ff1 100644 --- a/src/FSharp.Formatting.Common/Templating.fs +++ b/src/FSharp.Formatting.Common/Templating.fs @@ -195,7 +195,7 @@ module internal SimpleTemplating = let path = Path.GetFullPath(outputFile) |> Path.GetDirectoryName Directory.CreateDirectory(path) |> ignore - with - | _ -> () + with _ -> + () File.WriteAllText(outputFile, outputText) diff --git a/src/FSharp.Formatting.Common/YaafFSharpScripting.fs b/src/FSharp.Formatting.Common/YaafFSharpScripting.fs index a0d705f73..f25c04ca5 100644 --- a/src/FSharp.Formatting.Common/YaafFSharpScripting.fs +++ b/src/FSharp.Formatting.Common/YaafFSharpScripting.fs @@ -925,8 +925,7 @@ type internal FsiSession saveOutput () |> ignore session) - with - | e -> + with e -> let err, out, _ = getMessages () raise @@ -943,8 +942,7 @@ type internal FsiSession redirectOut (fun () -> let res = f text saveOutput (), res) - with - | e -> + with e -> let err, out, inp = getMessages () raise diff --git a/src/FSharp.Formatting.Literate/Evaluator.fs b/src/FSharp.Formatting.Literate/Evaluator.fs index bf911eefa..6b01ff5b3 100644 --- a/src/FSharp.Formatting.Literate/Evaluator.fs +++ b/src/FSharp.Formatting.Literate/Evaluator.fs @@ -377,8 +377,8 @@ module __FsiSettings = if depth > 20 then try sprintf "%A" v - with - | e -> e.ToString() + with e -> + e.ToString() else plainTextPrinters // Try to find a printer or print transformer @@ -387,21 +387,21 @@ module __FsiSettings = | Choice1Of2 addedPrinter -> try addedPrinter v - with - | _ -> None + with _ -> + None | Choice2Of2 addedPrintTransformer -> (try addedPrintTransformer v - with - | _ -> None) + with _ -> + None) |> Option.map (plainTextPrint (depth + 1))) |> function | None -> // no printer found try sprintf "%A" v - with - | e -> e.ToString() + with e -> + e.ToString() | Some t -> t let rec tryHtmlPrint depth (v: obj) = @@ -415,13 +415,13 @@ module __FsiSettings = | Choice1Of2 addedPrinter -> try addedPrinter v - with - | _ -> None + with _ -> + None | Choice2Of2 addedPrintTransformer -> (try addedPrintTransformer v - with - | _ -> None) + with _ -> + None) |> Option.bind (tryHtmlPrint (depth + 1))) /// Registered transformations for pretty printing values @@ -555,8 +555,7 @@ module __FsiSettings = Result = value ItValue = itvalue } :> IFsiEvaluationResult) - with - | :? FsiEvaluationException as e -> + with :? FsiEvaluationException as e -> evalFailed.Trigger { File = file AsExpression = asExpression diff --git a/src/fsdocs-tool/BuildCommand.fs b/src/fsdocs-tool/BuildCommand.fs index 37cfc114a..396e73a60 100644 --- a/src/fsdocs-tool/BuildCommand.fs +++ b/src/fsdocs-tool/BuildCommand.fs @@ -101,8 +101,8 @@ type internal DocContent let markdownReferenceAsFullInputPathOpt = try Path.GetFullPath(markdownReference, inputFolderAsGiven) |> Some - with - | _ -> None + with _ -> + None match markdownReferenceAsFullInputPathOpt with | None -> None @@ -120,8 +120,7 @@ type internal DocContent .ToString() Some uri - with - | _ -> + with _ -> printfn $"Couldn't map markdown reference {markdownReference} that seemed to correspond to an input file" @@ -210,31 +209,31 @@ type internal DocContent let fileChangeTime = try File.GetLastWriteTime(inputFileFullPath) - with - | _ -> DateTime.MaxValue + with _ -> + DateTime.MaxValue let templateChangeTime = match template with | Some t when isFsx || isMd -> try File.GetLastWriteTime(t) - with - | _ -> DateTime.MaxValue + with _ -> + DateTime.MaxValue | _ -> DateTime.MinValue let toolChangeTime = try File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location) - with - | _ -> DateTime.MaxValue + with _ -> + DateTime.MaxValue let changeTime = fileChangeTime |> max templateChangeTime |> max toolChangeTime let generateTime = try File.GetLastWriteTime(outputFileFullPath) - with - | _ -> System.DateTime.MinValue + with _ -> + System.DateTime.MinValue changeTime > generateTime @@ -330,8 +329,8 @@ type internal DocContent try File.Copy(inputFileFullPath, outputFileFullPath, true) File.SetLastWriteTime(outputFileFullPath, DateTime.Now) - with - | _ when watch -> ())) + with _ when watch -> + ())) else if mainRun && watch then //printfn "skipping unchanged file %s" inputFileFullPath yield (Some(inputFileFullPath, isOtherLang, haveModel.Value), (fun _ -> ())) ] @@ -547,8 +546,8 @@ type internal DocContent | Some s -> (try int32 s - with - | _ -> Int32.MaxValue) + with _ -> + Int32.MaxValue) | None -> Int32.MaxValue) [ @@ -571,8 +570,8 @@ type internal DocContent | Some s -> (try int32 s - with - | _ -> Int32.MaxValue) + with _ -> + Int32.MaxValue) | None -> Int32.MaxValue) match cat with @@ -746,8 +745,7 @@ type CoreBuildOptions(watch) = try f () true - with - | ex -> + with ex -> printfn "Error : \n%O" ex onError (sprintf "%s failed, and --strict is on : \n%O" phase ex) @@ -804,8 +802,8 @@ type CoreBuildOptions(watch) = let getTime p = try File.GetLastWriteTimeUtc(p) - with - | _ -> DateTime.Now + with _ -> + DateTime.Now let key1 = (userRoot, @@ -964,13 +962,13 @@ type CoreBuildOptions(watch) = None else if (try File.Exists(defaultTemplateAttempt1) - with - | _ -> false) then + with _ -> + false) then Some defaultTemplateAttempt1 elif (try File.Exists(defaultTemplateAttempt2) - with - | _ -> false) then + with _ -> + false) then Some defaultTemplateAttempt2 else None @@ -984,8 +982,8 @@ type CoreBuildOptions(watch) = if (try Directory.Exists(attempt1) - with - | _ -> false) then + with _ -> + false) then printfn "using extra content from %s" attempt1 (attempt1, ".") else @@ -997,8 +995,8 @@ type CoreBuildOptions(watch) = if (try Directory.Exists(attempt2) - with - | _ -> false) then + with _ -> + false) then printfn "using extra content from %s" attempt2 (attempt2, "content") else @@ -1227,8 +1225,8 @@ type CoreBuildOptions(watch) = if isOutputPathOK then try clean rootOutputFolderFullPath - with - | e -> printfn "warning: error during cleaning, continuing: %s" e.Message + with e -> + printfn "warning: error during cleaning, continuing: %s" e.Message else printfn "warning: skipping cleaning due to strange output path: \"%s\"" rootOutputFolderAsGiven @@ -1400,8 +1398,8 @@ type CoreBuildOptions(watch) = try Process.Start(new ProcessStartInfo(url, UseShellExecute = true)) |> ignore - with - | ex -> printfn "Warning, unable to launch browser(%s), try manually browsing to %s" ex.Message url + with ex -> + printfn "Warning, unable to launch browser(%s), try manually browsing to %s" ex.Message url waitForKey watch diff --git a/src/fsdocs-tool/ProjectCracker.fs b/src/fsdocs-tool/ProjectCracker.fs index 2a6f66054..0a3dbeff0 100644 --- a/src/fsdocs-tool/ProjectCracker.fs +++ b/src/fsdocs-tool/ProjectCracker.fs @@ -25,8 +25,8 @@ module Utils = let fileExists pathToFile = try File.Exists(pathToFile) - with - | _ -> false + with _ -> + false // Look for global install of dotnet sdk let getDotnetGlobalHostPath () = @@ -93,8 +93,8 @@ module Utils = let saveBinary (object: 'T) (fileName: string) = try Directory.CreateDirectory(Path.GetDirectoryName(fileName)) |> ignore - with - | _ -> () + with _ -> + () let formatter = DataContractSerializer(typeof<'T>) use fs = File.Create(fileName) @@ -113,8 +113,8 @@ module Utils = try let object = formatter.ReadObject(xw) :?> 'T Some object - with - | _ -> None + with _ -> + None let cacheBinary cacheFile cacheValid (f: unit -> 'T) : 'T = let attempt = @@ -452,8 +452,7 @@ module Crack = |> Array.choose (fun p -> try Some(crackProjectFile slnDir extraMsbuildProperties p) - with - | e -> + with e -> printfn " skipping project '%s' because an error occurred while cracking it: %O" (Path.GetFileName p) diff --git a/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs b/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs index 31c9bc4c7..dbc7a2815 100644 --- a/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs +++ b/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs @@ -70,8 +70,8 @@ let getOutputDir (format: OutputFormat) (uniq: string) = while (try Directory.Exists outDir - with - | _ -> false) do + with _ -> + false) do Directory.Delete(outDir, true) Directory.CreateDirectory(outDir).FullName @@ -114,16 +114,15 @@ let generateApiDocs (libraries: string list) (format: OutputFormat) useMdComment files - with - | e -> + with e -> printfn "Failed to Generate API Docs -\n%s\n\n%s\n" e.Message e.StackTrace System.AppDomain.CurrentDomain.GetAssemblies() |> Seq.iter (fun x -> try sprintf "%s\n - %s" x.FullName x.Location |> System.Console.WriteLine - with - | e -> sprintf "\nError On - %A\n -- %s\n" x e.Message |> System.Console.WriteLine) + with e -> + sprintf "\nError On - %A\n -- %s\n" x e.Message |> System.Console.WriteLine) reraise () @@ -1170,8 +1169,8 @@ let ``Metadata generates cross-type links for Inline Code`` (format: OutputForma let runtest testfn = try testfn () - with - | e -> printfn "Error -\n%s\n\nStackTrace -\n%s\n\n\TargetSite -\n%s\n" e.Message e.StackTrace e.TargetSite.Name + with e -> + printfn "Error -\n%s\n\nStackTrace -\n%s\n\n\TargetSite -\n%s\n" e.Message e.StackTrace e.TargetSite.Name #if INTERACTIVE printfn "Metadata generates cross-type links for Inline Code" runtest ``Metadata generates cross-type links for Inline Code`` diff --git a/tests/FSharp.Formatting.TestHelpers/TestHelpers.fs b/tests/FSharp.Formatting.TestHelpers/TestHelpers.fs index e21be84d7..824e80bb9 100644 --- a/tests/FSharp.Formatting.TestHelpers/TestHelpers.fs +++ b/tests/FSharp.Formatting.TestHelpers/TestHelpers.fs @@ -27,5 +27,5 @@ let enableLogging () = // Test that everything works Logging.infof "FSharp.Formatting Logging setup!" FSharp.Formatting.Internal.Log.infof "FSharp.Formatting.Internal Logging setup!" - with - | e -> printfn "FSharp.Formatting Logging setup failed: %A" e + with e -> + printfn "FSharp.Formatting Logging setup failed: %A" e diff --git a/tests/FSharp.Markdown.Tests/Externals.fs b/tests/FSharp.Markdown.Tests/Externals.fs index 301981334..284ec47e2 100644 --- a/tests/FSharp.Markdown.Tests/Externals.fs +++ b/tests/FSharp.Markdown.Tests/Externals.fs @@ -85,8 +85,7 @@ let executeTest (dir: string) (source: string) (target: string) (verify: string) None else None - with - | e -> + with e -> printfn " - %s (failed)\n %A" (target.Substring(dir.Length)) e None diff --git a/tests/FSharp.Markdown.Tests/TestFiles.fs b/tests/FSharp.Markdown.Tests/TestFiles.fs index 678f21dbd..a177e0708 100644 --- a/tests/FSharp.Markdown.Tests/TestFiles.fs +++ b/tests/FSharp.Markdown.Tests/TestFiles.fs @@ -64,8 +64,8 @@ let transformAndCompare transFunc (source: string) (target: string) (verify: str File.Delete(target) else printfn " - %s" (target.Substring(testdir.Length)) - with - | e -> printfn " - %s (failed)\n %A" (target.Substring(testdir.Length)) e + with e -> + printfn " - %s (failed)\n %A" (target.Substring(testdir.Length)) e let rec runTests dir = for file in Directory.GetFiles(dir, "*.text") do