diff --git a/.editorconfig b/.editorconfig index a7906cf2e3c..f7b9cea28dc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -74,4 +74,28 @@ indent_size = 4 # Either crlf | lf, default is system-dependent (when not specified at all) # end_of_line=crlf +# false: let a = [1;2;3] +# true: let a = [ 1;2;3 ] +# default true +fsharp_space_around_delimiter=true +# breaks a single-line record declaration +# i.e. if this gets too wide: { X = 10; Y = 12 } +# default 40 +fsharp_max_record_width=60 + +# breaks a record into one item per line if items exceed this number +# i.e. if set to 1, this will be on three lines: { X = 10; Y = 12 } +# requires fsharp_record_multiline_formatter=number_of_items to take effect +# default 1 +fsharp_max_record_number_of_items=1 + +# whether to use line-length (by counting chars) or items (by counting fields) +# for the record settings above +# either number_of_items or character_width +# default character_width +fsharp_record_multiline_formatter=character_width + +# set maximal number of consecutive blank lines to keep from original source +# it doesn't change number of new blank lines generated by Fantomas +fsharp_keep_max_number_of_blank_lines=2 diff --git a/build.fsx b/build.fsx index f34a27fb30a..b4308aef62d 100644 --- a/build.fsx +++ b/build.fsx @@ -111,9 +111,11 @@ let releaseSecret replacement name = match getVarOrDefaultFromVault name "default_unset" with | "default_unset" -> failwithf "variable '%s' is not set" name | s -> s + if BuildServer.buildServer <> BuildServer.TeamFoundation then // on TFS/VSTS the build will take care of this. TraceSecrets.register replacement env + env secrets <- secret :: secrets @@ -130,10 +132,12 @@ let chocoSource = getVarOrDefaultFromVault "CHOCO_SOURCE" "https://push.chocolatey.org/" let artifactsDir = getVarOrDefaultFromVault "ARTIFACTS_DIRECTORY" "" + let docsDomain = match BuildServer.isLocalBuild with | true -> "http://127.0.0.1:8083/" | false -> getVarOrDefaultFromVault "DOCS_DOMAIN" "fake.build" + let fromArtifacts = not <| String.isNullOrEmpty artifactsDir let apiKey = releaseSecret "" "NUGET_KEY" let chocoKey = releaseSecret "" "CHOCOLATEY_API_KEY" @@ -209,7 +213,9 @@ let version = let d = System.DateTime.Now let newLocalVersionNumber = currentVer + 1I - [ PreReleaseSegment.AlphaNumeric("local." + newLocalVersionNumber.ToString()) ], d.ToString("yyyy-MM-dd-HH-mm") + + [ PreReleaseSegment.AlphaNumeric("local." + newLocalVersionNumber.ToString()) ], + d.ToString("yyyy-MM-dd-HH-mm") let semVer = SemVer.parse release.NugetVersion @@ -220,11 +226,7 @@ let version = match String.IsNullOrWhiteSpace toAdd with | true -> None - | false -> - Some - { Name = "" - Values = source - Origin = toAdd } + | false -> Some { Name = ""; Values = source; Origin = toAdd } | Some p -> let toAdd = String.Join(".", source |> Seq.map segToString) let toAdd = if String.IsNullOrEmpty toAdd then toAdd else "." + toAdd @@ -450,9 +452,14 @@ let rec nugetPush tries nugetPackage = try if not <| String.IsNullOrEmpty apiKey.Value then let quoteString str = sprintf "\"%s\"" str - - let args = sprintf "push %s %s -Source %s" (quoteString nugetPackage) (quoteString apiKey.Value) (quoteString nugetSource) - + + let args = + sprintf + "push %s %s -Source %s" + (quoteString nugetPackage) + (quoteString apiKey.Value) + (quoteString nugetSource) + let errors = System.Collections.Generic.List() let results = System.Collections.Generic.List() @@ -470,22 +477,24 @@ let rec nugetPush tries nugetPackage = |> CreateProcess.redirectOutput |> CreateProcess.withOutputEventsNotNull errorF messageF |> Proc.run - + if processResult.ExitCode <> 0 then if not ignore_conflict || not (errors |> Seq.exists (fun err -> err.Contains "409")) then let msgs = - errors |> Seq.map (fun c -> "(Err) " + c) - |> Seq.append results |> Seq.map (fun c -> c) + errors + |> Seq.map (fun c -> "(Err) " + c) + |> Seq.append results + |> Seq.map (fun c -> c) let msg = String.Join("\n", msgs) failwithf "failed to push package %s (code %d): \n%s" nugetPackage processResult.ExitCode msg else Trace.traceFAKE "ignore conflict error because IGNORE_CONFLICT=true!" - + else Trace.traceFAKE "could not push '%s', because api key was not set" nugetPackage with exn when tries > 1 -> @@ -521,9 +530,7 @@ Target.create "Clean" (fun _ -> Shell.rm ("paket-files" "paket.restore.cached") callPaket "." "restore" - Shell.cleanDirs - [ nugetDncDir - collectedArtifactsDir ] + Shell.cleanDirs [ nugetDncDir; collectedArtifactsDir ] // Clean Data for tests cleanForTests ()) @@ -533,7 +540,9 @@ Target.create "CheckReleaseSecrets" (fun _ -> secret.Force() |> ignore) Target.create "CheckFormatting" (fun _ -> - let dotnetOptions = (fun (buildOptions:DotNet.Options) -> { buildOptions with RedirectOutput = false}) + let dotnetOptions = + (fun (buildOptions: DotNet.Options) -> { buildOptions with RedirectOutput = false }) + let result = DotNet.exec id "fantomas" "src/app/ src/template/ src/test/ --check" @@ -543,23 +552,22 @@ Target.create "CheckFormatting" (fun _ -> failwith "Some files need formatting, please run \"dotnet fantomas src/app/ src/template/ src/test/\" to resolve this." else - failwith "Errors while formatting" -) + failwith "Errors while formatting") // ---------------------------------------------------------------------------------------------------- // Documentation targets. Target.create "GenerateDocs" (fun _ -> let source = "./docs" - + Shell.cleanDir ".fsdocs" Directory.ensure "output" let projInfo = seq { - ("root", docsDomain) - ("fsdocs-logo-src", docsDomain @@ "content/img/logo.svg") - ("fsdocs-fake-version", simpleVersion) + ("root", docsDomain) + ("fsdocs-logo-src", docsDomain @@ "content/img/logo.svg") + ("fsdocs-fake-version", simpleVersion) } File.writeString false "./output/.nojekyll" "" @@ -568,26 +576,31 @@ Target.create "GenerateDocs" (fun _ -> try Npm.install (fun o -> { o with WorkingDirectory = "./docs" }) - + Npm.run "build" (fun o -> { o with WorkingDirectory = "./docs" }) - Shell.copy "./output" [source "robots.txt"] + Shell.copy "./output" [ source "robots.txt" ] // renaming node_modules directory so that fsdocs skip it when generating site. Directory.Move("./docs/node_modules", "./docs/.node_modules") - let command = sprintf "build --clean --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s" (docsDomain @@ "content/img/logo.svg") simpleVersion + let command = + sprintf + "build --clean --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s" + (docsDomain @@ "content/img/logo.svg") + simpleVersion + DotNet.exec id "fsdocs" command |> ignore - // Fsdocs.build (fun p -> { p with - // Input = Some(source) - // SaveImages = Some(true) - // Clean = Some(true) - // Parameters = Some projInfo - // Properties = Some "Configuration=debug" - // //Strict = Some(true) - // }) - + // Fsdocs.build (fun p -> { p with + // Input = Some(source) + // SaveImages = Some(true) + // Clean = Some(true) + // Parameters = Some projInfo + // Properties = Some "Configuration=debug" + // //Strict = Some(true) + // }) + finally // clean up Shell.rm (source "guide/RELEASE_NOTES.md") @@ -597,19 +610,31 @@ Target.create "GenerateDocs" (fun _ -> // validate site generation and ensure all components are generated successfully. - if DirectoryInfo.ofPath("./output/guide").GetFiles().Length = 0 then failwith "site generation failed due to missing guide directory" - if DirectoryInfo.ofPath("./output/reference").GetFiles().Length = 0 then failwith "site generation failed due to missing reference directory" - if DirectoryInfo.ofPath("./output/articles").GetFiles().Length = 0 then failwith "site generation failed due to missing articles directory" - if not (File.exists("./output/data.json")) then failwith "site generation failed due to missing data.json file" - if not (File.exists("./output/guide/RELEASE_NOTES.html")) then failwith "site generation failed due to missing RELEASE_NOTES.html file" - if not (File.exists("./output/guide.html")) then failwith "site generation failed due to missing guide.html file" - if not (File.exists("./output/index.html")) then failwith "site generation failed due to missing index.html file" + if DirectoryInfo.ofPath("./output/guide").GetFiles().Length = 0 then + failwith "site generation failed due to missing guide directory" + + if DirectoryInfo.ofPath("./output/reference").GetFiles().Length = 0 then + failwith "site generation failed due to missing reference directory" + + if DirectoryInfo.ofPath("./output/articles").GetFiles().Length = 0 then + failwith "site generation failed due to missing articles directory" + + if not (File.exists ("./output/data.json")) then + failwith "site generation failed due to missing data.json file" + + if not (File.exists ("./output/guide/RELEASE_NOTES.html")) then + failwith "site generation failed due to missing RELEASE_NOTES.html file" + + if not (File.exists ("./output/guide.html")) then + failwith "site generation failed due to missing guide.html file" + + if not (File.exists ("./output/index.html")) then + failwith "site generation failed due to missing index.html file" // prepare artifact Directory.ensure "temp" - - !!("output" "**/*") - |> Zip.zip docsDir "temp/docs.zip" + + !!("output" "**/*") |> Zip.zip docsDir "temp/docs.zip" publish "temp/docs.zip") Target.create "HostDocs" (fun _ -> @@ -622,15 +647,20 @@ Target.create "HostDocs" (fun _ -> Shell.copy (source @@ "guide") [ "RELEASE_NOTES.md" ] - Shell.copy "./output" [source "robots.txt"] - + Shell.copy "./output" [ source "robots.txt" ] + // renaming node_modules directory so that fsdocs skip it when generating site. Directory.Move("./docs/node_modules", "./docs/.node_modules") - let command = sprintf "watch --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s" (docsDomain @@ "content/img/logo.svg") simpleVersion + let command = + sprintf + "watch --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s" + (docsDomain @@ "content/img/logo.svg") + simpleVersion + DotNet.exec id "fsdocs" command |> ignore - // Fsdocs.watch id + // Fsdocs.watch id finally // clean up @@ -638,7 +668,7 @@ Target.create "HostDocs" (fun _ -> // renaming node_modules directory back after fsdocs generated site. Directory.Move("./docs/.node_modules", "./docs/node_modules") - + ) // ---------------------------------------------------------------------------------------------------- @@ -659,7 +689,7 @@ Target.create "TemplateIntegrationTests" (fun _ -> targetDir "bin/Release/net6.0/Fake.DotNet.Cli.IntegrationTests.dll" "Fake_DotNet_Cli_IntegrationTests.TestResults.xml" - + Shell.rm_rf (root "test")) Target.create "DotNetCoreUnitTests" (fun _ -> @@ -723,14 +753,16 @@ Target.create "BootstrapFake" (fun _ -> let processResult = - CreateProcess.fromRawCommandLine fileName (sprintf "run --fsiargs \"--define:BOOTSTRAP\" %s --target %s" script target) + CreateProcess.fromRawCommandLine + fileName + (sprintf "run --fsiargs \"--define:BOOTSTRAP\" %s --target %s" script target) |> CreateProcess.withWorkingDirectory "." |> CreateProcess.setEnvironmentVariable "FAKE_DETAILED_ERRORS" "true" |> CreateProcess.withTimeout timeout |> Proc.run - + processResult.ExitCode - + let result = executeTarget "BootstrapFake_PrintColors" if result <> 0 then @@ -967,11 +999,7 @@ Target.create "DotNetPushChocolateyPackage" (fun _ -> { p with ToolPath = altToolPath } path - |> Choco.push (fun p -> - { p with - Source = chocoSource - ApiKey = chocoKey.Value } - |> changeToolPath)) + |> Choco.push (fun p -> { p with Source = chocoSource; ApiKey = chocoKey.Value } |> changeToolPath)) Target.create "DotNetPushToNuGet" (fun _ -> !!(appDir "*/*.fsproj") -- (appDir "Fake.netcore/*.fsproj") @@ -1031,7 +1059,7 @@ Target.create "GitHubRelease" (fun _ -> |> GitHub.uploadFiles files |> GitHub.publishDraft |> Async.RunSynchronously - + let bumpVersionMessage = (sprintf "Bump version to %s" simpleVersion) let branch = "bump-version-to-" + simpleVersion Git.Staging.stageAll ".config" @@ -1041,9 +1069,12 @@ Target.create "GitHubRelease" (fun _ -> // when we release the GitHub module, this will be replaced with GitHub.createPullRequest API let pullRequest = new NewPullRequest(bumpVersionMessage, branch, "master") + let pullRequestTask (client: GitHubClient) = - client.PullRequest.Create(githubReleaseUser, gitName, pullRequest) |> Async.AwaitTask |> Async.RunSynchronously - + client.PullRequest.Create(githubReleaseUser, gitName, pullRequest) + |> Async.AwaitTask + |> Async.RunSynchronously + GitHub.createClientWithToken token |> Async.RunSynchronously |> pullRequestTask diff --git a/integrationtests/core-context-exists/before/context.exists.fsx b/integrationtests/core-context-exists/before/context.exists.fsx index 171599d8338..5fff8850b30 100644 --- a/integrationtests/core-context-exists/before/context.exists.fsx +++ b/integrationtests/core-context-exists/before/context.exists.fsx @@ -10,5 +10,5 @@ nuget Fake.Core.Context prerelease" #load ".fake/context.exists.fsx/intellisense.fsx" printfn "loading context" -let context = Fake.Core.Context.forceFakeContext() +let context = Fake.Core.Context.forceFakeContext () printfn "got: %A" context diff --git a/integrationtests/core-no-dependencies-hello-world/before/hello_world.fsx b/integrationtests/core-no-dependencies-hello-world/before/hello_world.fsx index fddb0bc0e8e..d85292c7ce8 100644 --- a/integrationtests/core-no-dependencies-hello-world/before/hello_world.fsx +++ b/integrationtests/core-no-dependencies-hello-world/before/hello_world.fsx @@ -1 +1 @@ -printfn "Hello FAKE" \ No newline at end of file +printfn "Hello FAKE" diff --git a/integrationtests/core-reference-fake-core-targets/before/otherfile.fs b/integrationtests/core-reference-fake-core-targets/before/otherfile.fs index 64aed3de9d7..14704919e4c 100644 --- a/integrationtests/core-reference-fake-core-targets/before/otherfile.fs +++ b/integrationtests/core-reference-fake-core-targets/before/otherfile.fs @@ -1,12 +1,11 @@ module OtherFile open Fake.Core + [] let createTargets () = - Target.create "OtherFileTarget" (fun _ -> - printfn "Doing Something." - ) + Target.create "OtherFileTarget" (fun _ -> printfn "Doing Something.") // required because otherwise JIT is still inlining this :( - printfn "test" \ No newline at end of file + printfn "test" diff --git a/integrationtests/core-reference-fake-core-targets/before/otherscript.fsx b/integrationtests/core-reference-fake-core-targets/before/otherscript.fsx index 608e5d5fba0..449b35f55f6 100644 --- a/integrationtests/core-reference-fake-core-targets/before/otherscript.fsx +++ b/integrationtests/core-reference-fake-core-targets/before/otherscript.fsx @@ -1,6 +1,4 @@ open Fake.Core -Target.initEnvironment() -Target.create "OtherScriptTarget" (fun _ -> - printfn "Doing Something." -) \ No newline at end of file +Target.initEnvironment () +Target.create "OtherScriptTarget" (fun _ -> printfn "Doing Something.") diff --git a/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx b/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx index 1c456b6c86b..3b04d44ff96 100644 --- a/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx +++ b/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx @@ -16,17 +16,16 @@ printfn "test_before open" open Fake.Core -let args : string[] option = Target.getArguments() +let args: string[] option = Target.getArguments () match args with -| Some args -> - printfn "GlobalArgs: %A" args +| Some args -> printfn "GlobalArgs: %A" args | None -> () #load "otherfile.fs" #load "otherscript.fsx" -OtherFile.createTargets() +OtherFile.createTargets () open Fake.Core.TargetOperators @@ -39,11 +38,9 @@ Target.create "TestTarget" (fun p -> printfn "Starting Build %A." {| test = "anon_record_f#-4.6" |} Trace.traceFAKE "Some Info from FAKE" printfn "Arguments: %A" p.Context.Arguments - printfn "Ending Build." -) + printfn "Ending Build.") -"Start" - ==> "TestTarget" +"Start" ==> "TestTarget" printfn "before run targets" diff --git a/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx b/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx index 16aa7195542..c0e0698fec7 100644 --- a/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx +++ b/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx @@ -11,4 +11,4 @@ open klajsdhgfasjkhd printfn asd Trace.traceFAKE "Some Info from FAKE" -printfn "Ending Build." \ No newline at end of file +printfn "Ending Build." diff --git a/integrationtests/core-simple-runtime-error/before/runtime-error.fsx b/integrationtests/core-simple-runtime-error/before/runtime-error.fsx index 146db82f730..a35ed3c9e38 100644 --- a/integrationtests/core-simple-runtime-error/before/runtime-error.fsx +++ b/integrationtests/core-simple-runtime-error/before/runtime-error.fsx @@ -9,4 +9,4 @@ // Issue https://github.com/fsharp/FAKE/issues/2121 System.Environment.CurrentDirectory <- System.IO.Path.GetFullPath "mydir" -failwith "runtime error" \ No newline at end of file +failwith "runtime error" diff --git a/integrationtests/i002007-native-libs/before/build.fsx b/integrationtests/i002007-native-libs/before/build.fsx index 82e0d922a87..3ed20f2e591 100644 --- a/integrationtests/i002007-native-libs/before/build.fsx +++ b/integrationtests/i002007-native-libs/before/build.fsx @@ -6,7 +6,7 @@ nuget System.Data.SQLite.Core //" open Fake.Core open System.Data.SQLite -let openConn (path:string) = +let openConn (path: string) = let builder = SQLiteConnectionStringBuilder() builder.DataSource <- path let conn = new SQLiteConnection(builder.ToString()) @@ -14,29 +14,31 @@ let openConn (path:string) = module Imports = open System.Runtime.InteropServices + [] extern uint32 GetCurrentProcessId() + [] extern uint32 UnknownFunctionInDll() + [] extern uint32 Fake_ShouldNotExistExtryPoint() // Default target Target.create "Default" (fun _ -> - Trace.trace "Hello World from FAKE" - if Environment.isWindows then - // #2342: make sure defaults PATH dependencies still work, see https://github.com/fsharp/FAKE/issues/2342 - printfn "Current process: %d" (Imports.GetCurrentProcessId()) - - use conn = openConn "temp.db" - () -) -Target.create "FailWithUnknown" (fun _ -> - printfn "UnknownFunctionInDll: %d" (Imports.UnknownFunctionInDll()) -) + Trace.trace "Hello World from FAKE" + + if Environment.isWindows then + // #2342: make sure defaults PATH dependencies still work, see https://github.com/fsharp/FAKE/issues/2342 + printfn "Current process: %d" (Imports.GetCurrentProcessId()) + + use conn = openConn "temp.db" + ()) + +Target.create "FailWithUnknown" (fun _ -> printfn "UnknownFunctionInDll: %d" (Imports.UnknownFunctionInDll())) + Target.create "FailWithMissingEntry" (fun _ -> - printfn "Fake_ShouldNotExistExtryPoint: %d" (Imports.Fake_ShouldNotExistExtryPoint()) -) + printfn "Fake_ShouldNotExistExtryPoint: %d" (Imports.Fake_ShouldNotExistExtryPoint())) // start build -Target.runOrDefault "Default" \ No newline at end of file +Target.runOrDefault "Default" diff --git a/integrationtests/i002025/before/script/build.fsx b/integrationtests/i002025/before/script/build.fsx index bc4b4a2e15a..6338419855f 100644 --- a/integrationtests/i002025/before/script/build.fsx +++ b/integrationtests/i002025/before/script/build.fsx @@ -1,4 +1,3 @@ - #r "paket: groupref build //" #load ".fake/build.fsx/intellisense.fsx" @@ -9,18 +8,12 @@ open Fake.IO.FileSystemOperators open Fake.IO.Globbing.Operators open Fake.Core.TargetOperators -Target.create "Clean" (fun _ -> - printfn ".. CLEAN .." -) +Target.create "Clean" (fun _ -> printfn ".. CLEAN ..") -Target.create "Build" (fun _ -> - printfn ".. Build .." -) +Target.create "Build" (fun _ -> printfn ".. Build ..") Target.create "All" ignore -"Clean" - ==> "Build" - ==> "All" +"Clean" ==> "Build" ==> "All" -Target.runOrDefault "All" \ No newline at end of file +Target.runOrDefault "All" diff --git a/modules/Octokit/Octokit.fsx b/modules/Octokit/Octokit.fsx index 2b7237d2292..109f54267c7 100644 --- a/modules/Octokit/Octokit.fsx +++ b/modules/Octokit/Octokit.fsx @@ -15,31 +15,40 @@ open System.Reflection open System.IO type Draft = - { Client : GitHubClient - Owner : string - Project : string - DraftRelease : Release } + { Client: GitHubClient + Owner: string + Project: string + DraftRelease: Release } // wrapper re-implementation of HttpClientAdapter which works around // known Octokit bug in which user-supplied timeouts are not passed to HttpClient object // https://github.com/octokit/octokit.net/issues/963 -type private HttpClientWithTimeout(timeout : TimeSpan) as this = +type private HttpClientWithTimeout(timeout: TimeSpan) as this = inherit HttpClientAdapter(fun () -> HttpMessageHandlerFactory.CreateDefault()) - let setter = lazy( - match typeof.GetField("_http", BindingFlags.NonPublic ||| BindingFlags.Instance) with - | null -> () - | f -> - match f.GetValue(this) with - | :? HttpClient as http -> http.Timeout <- timeout - | _ -> ()) + + let setter = + lazy + (match + typeof + .GetField("_http", BindingFlags.NonPublic ||| BindingFlags.Instance) + with + | null -> () + | f -> + match f.GetValue(this) with + | :? HttpClient as http -> http.Timeout <- timeout + | _ -> ()) interface IHttpClient with - member __.Send(request : IRequest, ct : CancellationToken) = + member __.Send(request: IRequest, ct: CancellationToken) = setter.Force() - match request with :? Request as r -> r.Timeout <- timeout | _ -> () + + match request with + | :? Request as r -> r.Timeout <- timeout + | _ -> () + base.Send(request, ct) -let private isRunningOnMono = System.Type.GetType ("Mono.Runtime") <> null +let private isRunningOnMono = System.Type.GetType("Mono.Runtime") <> null /// A version of 'reraise' that can work inside computation expressions let private captureAndReraise ex = @@ -68,11 +77,10 @@ let rec private retry count asyncF = let private retryWithArg count input asycnF = async { let! choice = input |> Async.Catch + match choice with - | Choice1Of2 input' -> - return! (asycnF input') |> retry count - | Choice2Of2 ex -> - return captureAndReraise ex + | Choice1Of2 input' -> return! (asycnF input') |> retry count + | Choice2Of2 ex -> return captureAndReraise ex } let createClient user (password: string) = @@ -97,7 +105,16 @@ let createGHEClient url user (password: string) = async { let credentials = Credentials(user, password) let httpClient = new HttpClientWithTimeout(TimeSpan.FromMinutes 20.) - let connection = new Connection(new ProductHeaderValue("FAKE"), new Uri(url), new InMemoryCredentialStore(credentials), httpClient, new SimpleJsonSerializer()) + + let connection = + new Connection( + new ProductHeaderValue("FAKE"), + new Uri(url), + new InMemoryCredentialStore(credentials), + httpClient, + new SimpleJsonSerializer() + ) + let github = new GitHubClient(connection) github.Credentials <- credentials return github @@ -107,111 +124,157 @@ let createGHEClientWithToken url token = async { let credentials = Credentials(token) let httpClient = new HttpClientWithTimeout(TimeSpan.FromMinutes 20.) - let connection = new Connection(new ProductHeaderValue("FAKE"), new Uri(url), new InMemoryCredentialStore(credentials), httpClient, new SimpleJsonSerializer()) + + let connection = + new Connection( + new ProductHeaderValue("FAKE"), + new Uri(url), + new InMemoryCredentialStore(credentials), + httpClient, + new SimpleJsonSerializer() + ) + let github = new GitHubClient(connection) github.Credentials <- credentials return github } -let private makeRelease draft owner project version prerelease (notes:seq) (client : Async) = - retryWithArg 5 client <| fun client' -> async { - let data = new NewRelease(version) - data.Name <- version - data.Body <- String.Join(Environment.NewLine, notes) - data.Draft <- draft - data.Prerelease <- prerelease - let! draft = Async.AwaitTask <| client'.Repository.Release.Create(owner, project, data) - let draftWord = if data.Draft then " draft" else "" - printfn "Created%s release id %d" draftWord draft.Id - return { - Client = client' - Owner = owner - Project = project - DraftRelease = draft } - } +let private makeRelease draft owner project version prerelease (notes: seq) (client: Async) = + retryWithArg 5 client + <| fun client' -> + async { + let data = new NewRelease(version) + data.Name <- version + data.Body <- String.Join(Environment.NewLine, notes) + data.Draft <- draft + data.Prerelease <- prerelease + let! draft = Async.AwaitTask <| client'.Repository.Release.Create(owner, project, data) + let draftWord = if data.Draft then " draft" else "" + printfn "Created%s release id %d" draftWord draft.Id + + return + { Client = client' + Owner = owner + Project = project + DraftRelease = draft } + } + +let createDraft owner project version prerelease notes client = + makeRelease true owner project version prerelease notes client -let createDraft owner project version prerelease notes client = makeRelease true owner project version prerelease notes client -let createRelease owner project version prerelease notes client = makeRelease false owner project version prerelease notes client +let createRelease owner project version prerelease notes client = + makeRelease false owner project version prerelease notes client + +let uploadFile fileName (draft: Async) = + retryWithArg 5 draft + <| fun draft' -> + async { + let fi = FileInfo(fileName) + let archiveContents = File.OpenRead(fi.FullName) + + let assetUpload = + new ReleaseAssetUpload(fi.Name, "application/octet-stream", archiveContents, Nullable()) + + let! asset = + Async.AwaitTask + <| draft'.Client.Repository.Release.UploadAsset(draft'.DraftRelease, assetUpload) + + printfn "Uploaded %s" asset.Name + return draft' + } -let uploadFile fileName (draft : Async) = - retryWithArg 5 draft <| fun draft' -> async { - let fi = FileInfo(fileName) - let archiveContents = File.OpenRead(fi.FullName) - let assetUpload = new ReleaseAssetUpload(fi.Name,"application/octet-stream",archiveContents,Nullable()) - let! asset = Async.AwaitTask <| draft'.Client.Repository.Release.UploadAsset(draft'.DraftRelease, assetUpload) - printfn "Uploaded %s" asset.Name +let uploadFiles fileNames (draft: Async) = + async { + let! draft' = draft + let draftW = async { return draft' } + let! _ = Async.Parallel [ for f in fileNames -> uploadFile f draftW ] return draft' } -let uploadFiles fileNames (draft : Async) = async { - let! draft' = draft - let draftW = async { return draft' } - let! _ = Async.Parallel [for f in fileNames -> uploadFile f draftW ] - return draft' -} - -let releaseDraft (draft : Async) = - retryWithArg 5 draft <| fun draft' -> async { - let update = draft'.DraftRelease.ToUpdate() - update.Draft <- Nullable(false) - let! released = Async.AwaitTask <| draft'.Client.Repository.Release.Edit(draft'.Owner, draft'.Project, draft'.DraftRelease.Id, update) - printfn "Released %d on github" released.Id - } +let releaseDraft (draft: Async) = + retryWithArg 5 draft + <| fun draft' -> + async { + let update = draft'.DraftRelease.ToUpdate() + update.Draft <- Nullable(false) -let getLastRelease owner project (client : Async) = - retryWithArg 5 client <| fun client' -> async { - let! draft = Async.AwaitTask <| client'.Repository.Release.GetLatest(owner, project) + let! released = + Async.AwaitTask + <| draft'.Client.Repository.Release.Edit(draft'.Owner, draft'.Project, draft'.DraftRelease.Id, update) - printfn "Latest release id: %d" draft.Id - printfn "Latest release tag: %s" draft.TagName - printfn "Latest release assets: %d" (Seq.length draft.Assets) + printfn "Released %d on github" released.Id + } - return { - Client = client' - Owner = owner - Project = project - DraftRelease = draft } - } +let getLastRelease owner project (client: Async) = + retryWithArg 5 client + <| fun client' -> + async { + let! draft = Async.AwaitTask <| client'.Repository.Release.GetLatest(owner, project) -let getReleaseByTag (owner:string) (project:string) (tag:string) (client : Async) = - retryWithArg 5 client <| fun client' -> async { - let! drafts = client'.Repository.Release.GetAll(owner, project) |> Async.AwaitTask - let matches = drafts |> Seq.filter (fun (r: Release) -> r.TagName = tag) + printfn "Latest release id: %d" draft.Id + printfn "Latest release tag: %s" draft.TagName + printfn "Latest release assets: %d" (Seq.length draft.Assets) - if Seq.isEmpty matches then - failwithf "Unable to locate tag %s" tag + return + { Client = client' + Owner = owner + Project = project + DraftRelease = draft } + } - let draft = matches |> Seq.head +let getReleaseByTag (owner: string) (project: string) (tag: string) (client: Async) = + retryWithArg 5 client + <| fun client' -> + async { + let! drafts = client'.Repository.Release.GetAll(owner, project) |> Async.AwaitTask + let matches = drafts |> Seq.filter (fun (r: Release) -> r.TagName = tag) - printfn "Release id: %d" draft.Id - printfn "Release tag: %s" draft.TagName - printfn "Release assets: %d" (Seq.length draft.Assets) + if Seq.isEmpty matches then + failwithf "Unable to locate tag %s" tag - return { - Client = client' - Owner = owner - Project = project - DraftRelease = draft } - } + let draft = matches |> Seq.head -let downloadAsset id destination (draft : Async) = - retryWithArg 5 draft <| fun draft' -> async { - let! asset = Async.AwaitTask <| draft'.Client.Repository.Release.GetAsset(draft'.Owner,draft'.Project,id) - let! resp = Async.AwaitTask <| draft'.Client.Connection.Get(new Uri(asset.Url), new System.Collections.Generic.Dictionary(),"application/octet-stream") + printfn "Release id: %d" draft.Id + printfn "Release tag: %s" draft.TagName + printfn "Release assets: %d" (Seq.length draft.Assets) - let bytes = resp.HttpResponse.Body :?> byte[] - let filename = Path.Combine(destination, asset.Name) + return + { Client = client' + Owner = owner + Project = project + DraftRelease = draft } + } - File.WriteAllBytes(filename, bytes) +let downloadAsset id destination (draft: Async) = + retryWithArg 5 draft + <| fun draft' -> + async { + let! asset = + Async.AwaitTask + <| draft'.Client.Repository.Release.GetAsset(draft'.Owner, draft'.Project, id) - printfn "Downloaded %s" filename - } + let! resp = + Async.AwaitTask + <| draft'.Client.Connection.Get( + new Uri(asset.Url), + new System.Collections.Generic.Dictionary(), + "application/octet-stream" + ) -let downloadAssets destination (draft : Async) = async { - let! draft' = draft - let draftW = async { return draft' } + let bytes = resp.HttpResponse.Body :?> byte[] + let filename = Path.Combine(destination, asset.Name) - let! _ = Async.Parallel [for f in draft'.DraftRelease.Assets -> downloadAsset f.Id destination draftW ] + File.WriteAllBytes(filename, bytes) + + printfn "Downloaded %s" filename + } - () -} +let downloadAssets destination (draft: Async) = + async { + let! draft' = draft + let draftW = async { return draft' } + + let! _ = Async.Parallel [ for f in draft'.DraftRelease.Assets -> downloadAsset f.Id destination draftW ] + + () + } diff --git a/src/app/Fake.Api.Slack/SlackNotification.fs b/src/app/Fake.Api.Slack/SlackNotification.fs index 986fc7c1f21..e4af9e3d889 100644 --- a/src/app/Fake.Api.Slack/SlackNotification.fs +++ b/src/app/Fake.Api.Slack/SlackNotification.fs @@ -81,10 +81,7 @@ module Slack = Fields = Array.empty } /// The default parameters for Slack notification attachment fields - let NotificationAttachmentFieldDefaults = - { Title = "" - Value = "" - Short = false } + let NotificationAttachmentFieldDefaults = { Title = ""; Value = ""; Short = false } let private lowerCaseContractResolver = { new Newtonsoft.Json.Serialization.DefaultContractResolver() with diff --git a/src/app/Fake.Azure.Kudu/Kudu.fs b/src/app/Fake.Azure.Kudu/Kudu.fs index bb906a25478..9dffbfd3abb 100644 --- a/src/app/Fake.Azure.Kudu/Kudu.fs +++ b/src/app/Fake.Azure.Kudu/Kudu.fs @@ -158,10 +158,7 @@ module Kudu = let response = client - .PostAsync( - zipDeployParams.Url.AbsoluteUri + "api/zipdeploy", - content - ) + .PostAsync(zipDeployParams.Url.AbsoluteUri + "api/zipdeploy", content) .Result response.StatusCode diff --git a/src/app/Fake.Build.CMake/CMake.fs b/src/app/Fake.Build.CMake/CMake.fs index ec2fd89db68..d4f95e4e0fa 100644 --- a/src/app/Fake.Build.CMake/CMake.fs +++ b/src/app/Fake.Build.CMake/CMake.fs @@ -238,10 +238,10 @@ module CMake = "-D " + option.Name + match option.Value with - | CMakeBoolean (value) -> ":BOOL=" + if value then "ON" else "OFF" - | CMakeString (value) -> ":STRING=\"" + value + "\"" - | CMakeDirPath (value) -> FormatCMakePath value |> sprintf ":PATH=\"%s\"" - | CMakeFilePath (value) -> FormatCMakePath value |> sprintf ":FILEPATH=\"%s\"") + | CMakeBoolean(value) -> ":BOOL=" + if value then "ON" else "OFF" + | CMakeString(value) -> ":STRING=\"" + value + "\"" + | CMakeDirPath(value) -> FormatCMakePath value |> sprintf ":PATH=\"%s\"" + | CMakeFilePath(value) -> FormatCMakePath value |> sprintf ":FILEPATH=\"%s\"") let cacheEntriesToRemove = argsIfNotEmpty "-U \"%s\"" parameters.CacheEntriesToRemove diff --git a/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs b/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs index 87c89132679..ac05a125cd0 100644 --- a/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs +++ b/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs @@ -284,31 +284,31 @@ module AppVeyor = let color = ConsoleWriter.colorMap msg match msg with - | TraceData.OpenTag (KnownTags.Test name, _) -> + | TraceData.OpenTag(KnownTags.Test name, _) -> AppVeyorInternal.StartTestCase (getCurrentTestSuite ()) name - | TraceData.TestOutput (_, out, err) -> currentTestOutput <- Some(out, err) - | TraceData.TestStatus (_, status) -> currentTestResult <- Some status - | TraceData.CloseTag (KnownTags.Test name, time, _) -> + | TraceData.TestOutput(_, out, err) -> currentTestOutput <- Some(out, err) + | TraceData.TestStatus(_, status) -> currentTestResult <- Some status + | TraceData.CloseTag(KnownTags.Test name, time, _) -> let outcome, msg, detail = match currentTestResult with | None -> "Passed", "", "" - | Some (TestStatus.Ignored msg) -> "Ignored", msg, "" - | Some (TestStatus.Failed (message, detail, None)) -> "Failed", message, detail - | Some (TestStatus.Failed (message, detail, Some (expected, actual))) -> + | Some(TestStatus.Ignored msg) -> "Ignored", msg, "" + | Some(TestStatus.Failed(message, detail, None)) -> "Failed", message, detail + | Some(TestStatus.Failed(message, detail, Some(expected, actual))) -> "Failed", sprintf "%s: Expected '%s' but was '%s'" message expected actual, detail let stdOut, stdErr = match currentTestOutput with - | Some (out, err) -> out, err + | Some(out, err) -> out, err | None -> "", "" AppVeyorInternal.UpdateTestEx (getCurrentTestSuite ()) name outcome msg detail stdOut stdErr AppVeyorInternal.FinishTestCase (getCurrentTestSuite ()) name time - | TraceData.OpenTag (KnownTags.TestSuite name, _) -> currentTestSuite <- Some name - | TraceData.CloseTag (KnownTags.TestSuite _, _, _) -> currentTestSuite <- None - | TraceData.BuildState (state, _) -> + | TraceData.OpenTag(KnownTags.TestSuite name, _) -> currentTestSuite <- Some name + | TraceData.CloseTag(KnownTags.TestSuite _, _, _) -> currentTestSuite <- None + | TraceData.BuildState(state, _) -> ConsoleWriter.writeAnsiColor false color true (sprintf "Changing BuildState to: %A" state) - | TraceData.OpenTag (tag, descr) -> + | TraceData.OpenTag(tag, descr) -> match descr with | Some d -> ConsoleWriter.writeAnsiColor @@ -317,7 +317,7 @@ module AppVeyor = true (sprintf "Starting %s '%s': %s" tag.Type tag.Name d) | _ -> ConsoleWriter.writeAnsiColor false color true (sprintf "Starting %s '%s'" tag.Type tag.Name) - | TraceData.CloseTag (tag, time, state) -> + | TraceData.CloseTag(tag, time, state) -> ConsoleWriter.writeAnsiColor false color @@ -329,25 +329,23 @@ module AppVeyor = | TraceData.ErrorMessage text -> ConsoleWriter.writeAnsiColor false color true text AppVeyorInternal.AddMessage AppVeyorInternal.MessageCategory.Error "" text - | TraceData.LogMessage (text, newLine) - | TraceData.TraceMessage (text, newLine) -> ConsoleWriter.writeAnsiColor false color newLine text - | TraceData.ImportData (ImportData.Nunit NunitDataVersion.Nunit, path) -> + | TraceData.LogMessage(text, newLine) + | TraceData.TraceMessage(text, newLine) -> ConsoleWriter.writeAnsiColor false color newLine text + | TraceData.ImportData(ImportData.Nunit NunitDataVersion.Nunit, path) -> AppVeyorInternal.UploadTestResultsFile AppVeyorInternal.TestResultsType.NUnit path - | TraceData.ImportData (ImportData.Nunit NunitDataVersion.Nunit3, path) -> + | TraceData.ImportData(ImportData.Nunit NunitDataVersion.Nunit3, path) -> AppVeyorInternal.UploadTestResultsFile AppVeyorInternal.TestResultsType.NUnit3 path - | TraceData.ImportData (ImportData.Mstest, path) -> + | TraceData.ImportData(ImportData.Mstest, path) -> AppVeyorInternal.UploadTestResultsFile AppVeyorInternal.TestResultsType.MsTest path - | TraceData.ImportData (ImportData.Xunit, path) -> + | TraceData.ImportData(ImportData.Xunit, path) -> AppVeyorInternal.UploadTestResultsFile AppVeyorInternal.TestResultsType.Xunit path - | TraceData.ImportData (ImportData.Junit, path) -> + | TraceData.ImportData(ImportData.Junit, path) -> AppVeyorInternal.UploadTestResultsFile AppVeyorInternal.TestResultsType.JUnit path - | TraceData.ImportData (ImportData.BuildArtifactWithName _, path) - | TraceData.ImportData (ImportData.BuildArtifact, path) -> + | TraceData.ImportData(ImportData.BuildArtifactWithName _, path) + | TraceData.ImportData(ImportData.BuildArtifact, path) -> AppVeyorInternal.PushArtifact(fun parms -> - { parms with - Path = path - FileName = Path.GetFileName path }) - | TraceData.ImportData (typ, path) -> + { parms with Path = path; FileName = Path.GetFileName path }) + | TraceData.ImportData(typ, path) -> AppVeyorInternal.PushArtifact(fun parms -> { parms with Path = path diff --git a/src/app/Fake.BuildServer.AppVeyor/AppVeyorInternal.fs b/src/app/Fake.BuildServer.AppVeyor/AppVeyorInternal.fs index b986e4f29fc..85c6eea6731 100644 --- a/src/app/Fake.BuildServer.AppVeyor/AppVeyorInternal.fs +++ b/src/app/Fake.BuildServer.AppVeyor/AppVeyorInternal.fs @@ -184,7 +184,4 @@ module internal AppVeyorInternal = /// Push multiple artifacts let PushArtifacts paths = for path in paths do - PushArtifact(fun p -> - { p with - Path = path - FileName = Path.GetFileName(path) }) + PushArtifact(fun p -> { p with Path = path; FileName = Path.GetFileName(path) }) diff --git a/src/app/Fake.BuildServer.GitHubActions/GitHubActions.fs b/src/app/Fake.BuildServer.GitHubActions/GitHubActions.fs index f9447fc8109..22c31d7c9d8 100644 --- a/src/app/Fake.BuildServer.GitHubActions/GitHubActions.fs +++ b/src/app/Fake.BuildServer.GitHubActions/GitHubActions.fs @@ -92,21 +92,21 @@ module GitHubActions = match msg with | TraceData.ImportantMessage text | TraceData.ErrorMessage text -> write true color true text - | TraceData.LogMessage (text, newLine) - | TraceData.TraceMessage (text, newLine) -> write false color newLine text - | TraceData.OpenTag (tag, descr) -> + | TraceData.LogMessage(text, newLine) + | TraceData.TraceMessage(text, newLine) -> write false color newLine text + | TraceData.OpenTag(tag, descr) -> match descr with | Some d -> write false color true (sprintf "Starting %s '%s': %s" tag.Type tag.Name d) | _ -> write false color true (sprintf "Starting %s '%s'" tag.Type tag.Name) - | TraceData.CloseTag (tag, time, state) -> + | TraceData.CloseTag(tag, time, state) -> write false color true (sprintf "Finished (%A) '%s' in %O" state tag.Name time) - | TraceData.ImportData (typ, path) -> write false color true (sprintf "Import data '%O': %s" typ path) - | TraceData.TestOutput (test, out, err) -> + | TraceData.ImportData(typ, path) -> write false color true (sprintf "Import data '%O': %s" typ path) + | TraceData.TestOutput(test, out, err) -> write false color true (sprintf "Test '%s' output:\n\tOutput: %s\n\tError: %s" test out err) | TraceData.BuildNumber number -> write false color true (sprintf "Build Number: %s" number) - | TraceData.TestStatus (test, status) -> + | TraceData.TestStatus(test, status) -> write false color true (sprintf "Test '%s' status: %A" test status) - | TraceData.BuildState (state, _) -> write false color true (sprintf "Build State: %A" state) + | TraceData.BuildState(state, _) -> write false color true (sprintf "Build State: %A" state) /// [omit] let defaultTraceListener = GitHubActionsTraceListener() :> ITraceListener diff --git a/src/app/Fake.BuildServer.GitLab/GitLab.fs b/src/app/Fake.BuildServer.GitLab/GitLab.fs index 1e0c24736e4..2f6d3bf03f3 100644 --- a/src/app/Fake.BuildServer.GitLab/GitLab.fs +++ b/src/app/Fake.BuildServer.GitLab/GitLab.fs @@ -254,26 +254,26 @@ module GitLab = match msg with | TraceData.ImportantMessage text | TraceData.ErrorMessage text -> write importantMessagesToStdErr color true text - | TraceData.LogMessage (text, newLine) - | TraceData.TraceMessage (text, newLine) -> write false color newLine text - | TraceData.OpenTag (tag, descr) -> + | TraceData.LogMessage(text, newLine) + | TraceData.TraceMessage(text, newLine) -> write false color newLine text + | TraceData.OpenTag(tag, descr) -> match descr with | Some d -> write false color true (sprintf "Starting %s '%s': %s" tag.Type tag.Name d) | _ -> write false color true (sprintf "Starting %s '%s'" tag.Type tag.Name) - | TraceData.CloseTag (tag, time, state) -> + | TraceData.CloseTag(tag, time, state) -> write false color true (sprintf "Finished (%A) '%s' in %O" state tag.Name time) - | TraceData.BuildState (state, _) -> write false color true (sprintf "Changing BuildState to: %A" state) - | TraceData.ImportData (typ, path) -> + | TraceData.BuildState(state, _) -> write false color true (sprintf "Changing BuildState to: %A" state) + | TraceData.ImportData(typ, path) -> let name = Path.GetFileName path let target = Path.Combine("artifacts", name) let targetDir = Path.GetDirectoryName target Directory.ensure targetDir Shell.cp_r path target write false color true (sprintf "Import data '%O': %s -> %s" typ path target) - | TraceData.TestOutput (test, out, err) -> + | TraceData.TestOutput(test, out, err) -> write false color true (sprintf "Test '%s' output:\n\tOutput: %s\n\tError: %s" test out err) | TraceData.BuildNumber number -> write false color true (sprintf "Build Number: %s" number) - | TraceData.TestStatus (test, status) -> + | TraceData.TestStatus(test, status) -> write false color true (sprintf "Test '%s' status: %A" test status) /// [omit] diff --git a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs index 5af6aae8fc2..87bab5cfb46 100644 --- a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs +++ b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs @@ -295,7 +295,7 @@ module TeamCity = let filePath = split[0] let modificationType = - match split[ 1 ].ToUpperInvariant() with + match split[1].ToUpperInvariant() with | "CHANGED" -> FileChanged | "ADDED" -> FileAdded | "REMOVED" -> FileRemoved @@ -401,42 +401,42 @@ module TeamCity = let color = ConsoleWriter.colorMap msg match msg with - | TraceData.OpenTag (KnownTags.Test name, _) -> startTestCase name - | TraceData.TestOutput (testName, out, err) -> + | TraceData.OpenTag(KnownTags.Test name, _) -> startTestCase name + | TraceData.TestOutput(testName, out, err) -> if not (String.IsNullOrEmpty out) then reportTestOutput testName out if not (String.IsNullOrEmpty err) then reportTestError testName err - | TraceData.TestStatus (testName, TestStatus.Ignored message) -> ignoreTestCase testName message - | TraceData.TestStatus (testName, TestStatus.Failed (message, detail, None)) -> + | TraceData.TestStatus(testName, TestStatus.Ignored message) -> ignoreTestCase testName message + | TraceData.TestStatus(testName, TestStatus.Failed(message, detail, None)) -> testFailed testName message detail - | TraceData.TestStatus (testName, TestStatus.Failed (message, detail, Some (expected, actual))) -> + | TraceData.TestStatus(testName, TestStatus.Failed(message, detail, Some(expected, actual))) -> comparisonFailure testName message detail expected actual - | TraceData.BuildState (TagStatus.Success, _) -> reportBuildStatus "SUCCESS" "{build.status.text}" - | TraceData.BuildState (TagStatus.Warning, None) -> warning "Setting build state to warning." - | TraceData.BuildState (TagStatus.Warning, Some message) -> warning message - | TraceData.BuildState (TagStatus.Failed, None) -> + | TraceData.BuildState(TagStatus.Success, _) -> reportBuildStatus "SUCCESS" "{build.status.text}" + | TraceData.BuildState(TagStatus.Warning, None) -> warning "Setting build state to warning." + | TraceData.BuildState(TagStatus.Warning, Some message) -> warning message + | TraceData.BuildState(TagStatus.Failed, None) -> reportBuildStatus "FAILURE" "Failure - {build.status.text}" - | TraceData.BuildState (TagStatus.Failed, Some message) -> + | TraceData.BuildState(TagStatus.Failed, Some message) -> reportBuildStatus "FAILURE" (sprintf "%s - {build.status.text}" message) - | TraceData.CloseTag (KnownTags.Test name, time, _) -> finishTestCase name time - | TraceData.OpenTag (KnownTags.TestSuite name, _) -> startTestSuite name - | TraceData.CloseTag (KnownTags.TestSuite name, _, _) -> finishTestSuite name - | TraceData.OpenTag (tag, description) -> + | TraceData.CloseTag(KnownTags.Test name, time, _) -> finishTestCase name time + | TraceData.OpenTag(KnownTags.TestSuite name, _) -> startTestSuite name + | TraceData.CloseTag(KnownTags.TestSuite name, _, _) -> finishTestSuite name + | TraceData.OpenTag(tag, description) -> match description with | Some d -> TeamCityWriter.sendOpenBlock tag.Name (sprintf "%s: %s" tag.Type d) | _ -> TeamCityWriter.sendOpenBlock tag.Name tag.Type - | TraceData.CloseTag (tag, _, _) -> TeamCityWriter.sendCloseBlock tag.Name + | TraceData.CloseTag(tag, _, _) -> TeamCityWriter.sendCloseBlock tag.Name | TraceData.ImportantMessage text -> warning text | TraceData.ErrorMessage text -> error text - | TraceData.LogMessage (text, newLine) - | TraceData.TraceMessage (text, newLine) -> ConsoleWriter.write false color newLine text - | TraceData.ImportData (ImportData.BuildArtifactWithName name, path) -> publishNamedArtifact name path - | TraceData.ImportData (ImportData.BuildArtifact, path) -> publishArtifact path - | TraceData.ImportData (ImportData.DotNetCoverage tool, path) -> + | TraceData.LogMessage(text, newLine) + | TraceData.TraceMessage(text, newLine) -> ConsoleWriter.write false color newLine text + | TraceData.ImportData(ImportData.BuildArtifactWithName name, path) -> publishNamedArtifact name path + | TraceData.ImportData(ImportData.BuildArtifact, path) -> publishArtifact path + | TraceData.ImportData(ImportData.DotNetCoverage tool, path) -> Import.sendDotNetCoverageForTool path tool - | TraceData.ImportData (typ, path) -> TeamCityWriter.sendImportData typ.TeamCityName path + | TraceData.ImportData(typ, path) -> TeamCityWriter.sendImportData typ.TeamCityName path | TraceData.BuildNumber number -> setBuildNumber number /// [omit] diff --git a/src/app/Fake.BuildServer.TeamCity/TeamCityInternal.fs b/src/app/Fake.BuildServer.TeamCity/TeamCityInternal.fs index 68537128a5e..7902b2f5911 100644 --- a/src/app/Fake.BuildServer.TeamCity/TeamCityInternal.fs +++ b/src/app/Fake.BuildServer.TeamCity/TeamCityInternal.fs @@ -47,18 +47,18 @@ module internal TeamCityWriter = let private sendToTeamCity (message: TeamCityMessage) = let content = match message with - | OneParamMultiLine (fmt, param1) -> sprintf fmt (encapsulateSpecialChars param1) - | OneParamSingleLine (fmt, param1) -> sprintf fmt (singleLine param1) - | TwoParamMultiLine (fmt, param1, param2) -> + | OneParamMultiLine(fmt, param1) -> sprintf fmt (encapsulateSpecialChars param1) + | OneParamSingleLine(fmt, param1) -> sprintf fmt (singleLine param1) + | TwoParamMultiLine(fmt, param1, param2) -> sprintf fmt (encapsulateSpecialChars param1) (encapsulateSpecialChars param2) - | TwoParamSingleLineBoth (fmt, param1, param2) -> sprintf fmt (singleLine param1) (singleLine param2) - | TwoParamSingleLineParam1 (fmt, param1, param2) -> + | TwoParamSingleLineBoth(fmt, param1, param2) -> sprintf fmt (singleLine param1) (singleLine param2) + | TwoParamSingleLineParam1(fmt, param1, param2) -> sprintf fmt (singleLine param1) (encapsulateSpecialChars param2) - | ThreeParamSingleLineAll (fmt, param1, param2, param3) -> + | ThreeParamSingleLineAll(fmt, param1, param2, param3) -> sprintf fmt (singleLine param1) (singleLine param2) (singleLine param3) - | ThreeParamSingleLineParam1 (fmt, param1, param2, param3) -> + | ThreeParamSingleLineParam1(fmt, param1, param2, param3) -> sprintf fmt (singleLine param1) (encapsulateSpecialChars param2) (encapsulateSpecialChars param3) - | FiveParamSingleLineParam1 (fmt, param1, param2, param3, param4, param5) -> + | FiveParamSingleLineParam1(fmt, param1, param2, param3, param4, param5) -> sprintf fmt (singleLine param1) @@ -394,7 +394,7 @@ module internal TeamCityBuildParameters = |> JavaPropertiesFile.parseTextReader |> Seq.choose (function | JavaPropertiesFile.Comment _ -> None - | JavaPropertiesFile.KeyValue (k, v) -> Some(k, v)) + | JavaPropertiesFile.KeyValue(k, v) -> Some(k, v)) |> Map.ofSeq | _ -> Map.empty diff --git a/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs b/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs index 96591ce33ce..bf36c797f6e 100644 --- a/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs +++ b/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs @@ -52,6 +52,7 @@ module TeamFoundation = let write action properties message = // https://github.com/Microsoft/vsts-task-lib/blob/3a7905b99d698a535d9f5a477efc124894b8d2ae/node/taskcommand.ts let ensurePropVal (s: string) = + // TODO: Rewrite to stringBuffer s .Replace("\r", "%0D") .Replace("\n", "%0A") @@ -99,10 +100,11 @@ module TeamFoundation = let typ = if isWarning then "warning" else "error" let parameters = - toList "type" (Some typ) - @ toList "sourcepath" sourcePath - @ toList "linenumber" lineNumber - @ toList "columnnumber" columnNumber @ toList "code" code + [ yield! toList "type" (Some typ) + yield! toList "sourcepath" sourcePath + yield! toList "linenumber" lineNumber + yield! toList "columnnumber" columnNumber + yield! toList "code" code ] write "task.logissue" parameters message @@ -180,16 +182,16 @@ module TeamFoundation = let internal logDetailRaw logDetailData = let parameters = - toList "id" (Some(string logDetailData.id)) - @ toList "parentid" (logDetailData.parentId |> Option.map string) - @ toList "type" logDetailData.typ - @ toList "name" logDetailData.name - @ toList "order" (logDetailData.order |> Option.map string) - @ toList "starttime" (logDetailData.startTime |> Option.map string) - @ toList "finishtime" (logDetailData.finishTime |> Option.map string) - @ toList "progress" (logDetailData.progress |> Option.map string) - @ toList "state" (logDetailData.state |> Option.map string) - @ toList "result" (logDetailData.result |> Option.map string) + [ yield! toList "id" (Some(string logDetailData.id)) + yield! toList "parentid" (logDetailData.parentId |> Option.map string) + yield! toList "type" logDetailData.typ + yield! toList "name" logDetailData.name + yield! toList "order" (logDetailData.order |> Option.map string) + yield! toList "starttime" (logDetailData.startTime |> Option.map string) + yield! toList "finishtime" (logDetailData.finishTime |> Option.map string) + yield! toList "progress" (logDetailData.progress |> Option.map string) + yield! toList "state" (logDetailData.state |> Option.map string) + yield! toList "result" (logDetailData.result |> Option.map string) ] write "task.logdetail" parameters logDetailData.message @@ -365,9 +367,9 @@ module TeamFoundation = match msg with | TraceData.ErrorMessage text -> logIssue false None None None None text | TraceData.ImportantMessage text -> logIssue true None None None None text - | TraceData.LogMessage (text, newLine) - | TraceData.TraceMessage (text, newLine) -> writeConsole false color newLine text - | TraceData.OpenTag (tag, descr) -> + | TraceData.LogMessage(text, newLine) + | TraceData.TraceMessage(text, newLine) -> writeConsole false color newLine text + | TraceData.OpenTag(tag, descr) -> let id = Guid.NewGuid() let parentId = @@ -381,7 +383,7 @@ module TeamFoundation = match descr with | Some d -> createLogDetail id parentId tag.Type tag.Name order d | _ -> createLogDetail id parentId tag.Type tag.Name order null - | TraceData.CloseTag (tag, time, state) -> + | TraceData.CloseTag(tag, time, state) -> ignore time let id, rest = @@ -400,7 +402,7 @@ module TeamFoundation = | TagStatus.Success -> LogDetailResult.Succeeded setLogDetailFinished id result - | TraceData.BuildState (state, _) -> + | TraceData.BuildState(state, _) -> let vsoState, msg = match state with | TagStatus.Success -> "Succeeded", "OK" @@ -408,17 +410,17 @@ module TeamFoundation = | TagStatus.Failed -> "Failed", "ERROR" setBuildState vsoState msg - | TraceData.ImportData (ImportData.Junit _, path) -> publishTests "JUnit" [ path ] false "" "" "" true - | TraceData.ImportData (ImportData.Nunit _, path) -> publishTests "NUnit" [ path ] false "" "" "" true - | TraceData.ImportData (ImportData.Mstest _, path) -> publishTests "VSTest" [ path ] false "" "" "" true - | TraceData.ImportData (ImportData.Xunit _, path) -> publishTests "XUnit" [ path ] false "" "" "" true - | TraceData.ImportData (ImportData.BuildArtifactWithName name, path) -> + | TraceData.ImportData(ImportData.Junit _, path) -> publishTests "JUnit" [ path ] false "" "" "" true + | TraceData.ImportData(ImportData.Nunit _, path) -> publishTests "NUnit" [ path ] false "" "" "" true + | TraceData.ImportData(ImportData.Mstest _, path) -> publishTests "VSTest" [ path ] false "" "" "" true + | TraceData.ImportData(ImportData.Xunit _, path) -> publishTests "XUnit" [ path ] false "" "" "" true + | TraceData.ImportData(ImportData.BuildArtifactWithName name, path) -> publishArtifactIfOk name (Some name) path - | TraceData.ImportData (typ, path) -> publishArtifactIfOk typ.Name (Some "fake-artifacts") path - | TraceData.TestOutput (test, out, err) -> + | TraceData.ImportData(typ, path) -> publishArtifactIfOk typ.Name (Some "fake-artifacts") path + | TraceData.TestOutput(test, out, err) -> writeConsole false color true (sprintf "Test '%s' output:\n\tOutput: %s\n\tError: %s" test out err) | TraceData.BuildNumber number -> setBuildNumber number - | TraceData.TestStatus (test, status) -> + | TraceData.TestStatus(test, status) -> writeConsole false color true (sprintf "Test '%s' status: %A" test status) /// [omit] diff --git a/src/app/Fake.BuildServer.Travis/Travis.fs b/src/app/Fake.BuildServer.Travis/Travis.fs index 070df535f8e..5d3ed6adbdc 100644 --- a/src/app/Fake.BuildServer.Travis/Travis.fs +++ b/src/app/Fake.BuildServer.Travis/Travis.fs @@ -26,21 +26,21 @@ module Travis = match msg with | TraceData.ImportantMessage text | TraceData.ErrorMessage text -> write true color true text - | TraceData.LogMessage (text, newLine) - | TraceData.TraceMessage (text, newLine) -> write false color newLine text - | TraceData.OpenTag (tag, descr) -> + | TraceData.LogMessage(text, newLine) + | TraceData.TraceMessage(text, newLine) -> write false color newLine text + | TraceData.OpenTag(tag, descr) -> match descr with | Some d -> write false color true (sprintf "Starting %s '%s': %s" tag.Type tag.Name d) | _ -> write false color true (sprintf "Starting %s '%s'" tag.Type tag.Name) - | TraceData.CloseTag (tag, time, state) -> + | TraceData.CloseTag(tag, time, state) -> write false color true (sprintf "Finished (%A) '%s' in %O" state tag.Name time) - | TraceData.ImportData (typ, path) -> write false color true (sprintf "Import data '%O': %s" typ path) - | TraceData.TestOutput (test, out, err) -> + | TraceData.ImportData(typ, path) -> write false color true (sprintf "Import data '%O': %s" typ path) + | TraceData.TestOutput(test, out, err) -> write false color true (sprintf "Test '%s' output:\n\tOutput: %s\n\tError: %s" test out err) | TraceData.BuildNumber number -> write false color true (sprintf "Build Number: %s" number) - | TraceData.TestStatus (test, status) -> + | TraceData.TestStatus(test, status) -> write false color true (sprintf "Test '%s' status: %A" test status) - | TraceData.BuildState (state, _) -> write false color true (sprintf "Build State: %A" state) + | TraceData.BuildState(state, _) -> write false color true (sprintf "Build State: %A" state) /// [omit] let defaultTraceListener = TravisTraceListener() :> ITraceListener diff --git a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Args.fs b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Args.fs index 0f287601441..da93ad7caa5 100644 --- a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Args.fs +++ b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Args.fs @@ -23,22 +23,22 @@ module DocoptResult = match Map.tryFind flag map with | Some NoResult -> 0 | Some Flag -> 1 - | Some (Flags n) -> n - | Some (Argument _) -> 1 - | Some (Arguments l) -> l.Length + | Some(Flags n) -> n + | Some(Argument _) -> 1 + | Some(Arguments l) -> l.Length | None -> 0 let hasFlag flag (map: DocoptMap) = getFlagCount flag map > 0 let tryGetArgument flag (map: DocoptMap) = match Map.tryFind flag map with - | Some (Argument arg) - | Some (Arguments [ arg ]) -> Some arg - | Some (Arguments args) -> failwithf "Expected argument %s only a single time, but got %A" flag args + | Some(Argument arg) + | Some(Arguments [ arg ]) -> Some arg + | Some(Arguments args) -> failwithf "Expected argument %s only a single time, but got %A" flag args | _ -> None let tryGetArguments flag (map: DocoptMap) = match Map.tryFind flag map with - | Some (Argument arg) -> Some [ arg ] - | Some (Arguments args) -> Some args + | Some(Argument arg) -> Some [ arg ] + | Some(Arguments args) -> Some args | _ -> None diff --git a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Ast.fs b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Ast.fs index eb83f5ea54d..7d884783e03 100644 --- a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Ast.fs +++ b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Ast.fs @@ -67,7 +67,7 @@ type UsageAst = | Req ast -> ast.ContainsOnlyOptions | Arg _ -> false | XorEmpty -> true - | Xor (l, r) -> l.ContainsOnlyOptions && r.ContainsOnlyOptions + | Xor(l, r) -> l.ContainsOnlyOptions && r.ContainsOnlyOptions | Seq asts -> asts |> Seq.forall (fun t -> t.ContainsOnlyOptions) | Cmd _ -> false | Ell ast -> ast.ContainsOnlyOptions @@ -118,14 +118,14 @@ and UsageAstCell = | Some c -> match c with | UsageAstBuilder.Eps -> UsageAst.Eps - | UsageAstBuilder.Ano (title, o') -> UsageAst.Ano(title, o') + | UsageAstBuilder.Ano(title, o') -> UsageAst.Ano(title, o') | UsageAstBuilder.Sop o' -> UsageAst.Sop o' | UsageAstBuilder.Lop o' -> UsageAst.Lop o' | UsageAstBuilder.Sqb ast' -> UsageAst.Sqb(ast'.Build()) | UsageAstBuilder.Req ast' -> UsageAst.Req(ast'.Build()) | UsageAstBuilder.Arg name' -> UsageAst.Arg name' | UsageAstBuilder.XorEmpty -> UsageAst.XorEmpty - | UsageAstBuilder.Xor (l', r') -> UsageAst.Xor(l'.Build(), r'.Build()) + | UsageAstBuilder.Xor(l', r') -> UsageAst.Xor(l'.Build(), r'.Build()) | UsageAstBuilder.Seq asts' -> UsageAst.Seq(asts' |> Seq.map (fun ast -> ast.Build()) |> Seq.toList) | UsageAstBuilder.Cmd cmd' -> UsageAst.Cmd cmd' | UsageAstBuilder.Ell ast' -> UsageAst.Ell(ast'.Build()) diff --git a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Docopt.fs b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Docopt.fs index 8d9c27679ea..f7c89e2f4e9 100644 --- a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Docopt.fs +++ b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/Docopt.fs @@ -63,19 +63,15 @@ module DocHelper = let cut (doc': string) = let folder (usages', (sections': OptionBuilder list), last') = function - | Usage (ustr) when String.IsNullOrWhiteSpace ustr -> (usages', sections', Last.Usage) - | Usage (ustr) -> (ustr :: usages', sections', Last.Usage) - | Options (sectionName, ostr) -> - (usages', - { Title = sectionName - Lines = [ ostr ] } - :: sections', - Last.Options) + | Usage(ustr) when String.IsNullOrWhiteSpace ustr -> (usages', sections', Last.Usage) + | Usage(ustr) -> (ustr :: usages', sections', Last.Usage) + | Options(sectionName, ostr) -> + (usages', { Title = sectionName; Lines = [ ostr ] } :: sections', Last.Options) //match sections' with //| options' :: sections' -> (usages', (ostr::options')::sections', Last.Options) //| [] -> (usages', [{ Title = sectionName; Lines = [ostr] }], Last.Options) | Newline -> (usages', sections', Last.Nothing) - | Other (line) -> + | Other(line) -> match last' with | Last.Usage when String.IsNullOrWhiteSpace line -> (usages', sections', Last.Usage) | Last.Usage -> (line :: usages', sections', Last.Usage) diff --git a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/OptionsParser.fs b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/OptionsParser.fs index 2e3dbf455f1..9a0b3a27113 100644 --- a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/OptionsParser.fs +++ b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/OptionsParser.fs @@ -170,7 +170,7 @@ type OptionsParser(soptChars': string) = match state.ArgName, newa' with | _, None -> state | None, _ -> { state with ArgName = newa' } - | Some (l), Some (r) -> { state with ArgName = Some(String.Concat(l, " or ", r)) } + | Some(l), Some(r) -> { state with ArgName = Some(String.Concat(l, " or ", r)) } match stream.Peek() with | ' ' -> stream.Skip() @@ -186,21 +186,9 @@ type OptionsParser(soptChars': string) = match r.Status with | Ok -> match r.Result with - | "[!]" -> - Reply - { state with - IsRequired = true - AllowMultiple = false } - | "[*]" -> - Reply - { state with - IsRequired = false - AllowMultiple = true } - | "[+]" -> - Reply - { state with - IsRequired = true - AllowMultiple = true } + | "[!]" -> Reply { state with IsRequired = true; AllowMultiple = false } + | "[*]" -> Reply { state with IsRequired = false; AllowMultiple = true } + | "[+]" -> Reply { state with IsRequired = true; AllowMultiple = true } | _ -> Reply(Error, ErrorMessageList(ExpectedString "[!], [*] or [+]")) | _ -> Reply(Error, r.Error) //``expecting hyphen 1`` stream' state @@ -235,7 +223,7 @@ type OptionsParser(soptChars': string) = match dflt with | Some dfltVal -> Val(dfltVal) | None -> Nil - | Success (r, _, _) -> Opt(r) + | Success(r, _, _) -> Opt(r) } in let options = ResizeArray<_>() in @@ -244,10 +232,10 @@ type OptionsParser(soptChars': string) = let action = function | Nil -> () - | Opt (opt) -> + | Opt(opt) -> lastOpt.Value <- Some opt options.Add(opt) - | Val (str) -> + | Val(str) -> match lastOpt.Value with // In order to parse defaults from follow-up lines... | Some lastOptCopy -> lastOptCopy.DefaultValue <- Some str | None -> () in diff --git a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/UsageParser.fs b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/UsageParser.fs index 53d486e3111..a4f22462438 100644 --- a/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/UsageParser.fs +++ b/src/app/Fake.Core.CommandLineParsing/docopt.fs/Docopt/UsageParser.fs @@ -61,22 +61,22 @@ type ArgumentStreamPosition = override x.ToString() = match x with | ArgumentPos p -> sprintf "ArgumentPos(%d)" p - | ShortArgumentPartialPos (p, part) -> sprintf "ArgumentPos(%d, %d)" p part + | ShortArgumentPartialPos(p, part) -> sprintf "ArgumentPos(%d, %d)" p part member x.ArgIndex = match x with - | ShortArgumentPartialPos (p, _) + | ShortArgumentPartialPos(p, _) | ArgumentPos p -> p member x.InnerIndex = match x with - | ShortArgumentPartialPos (_, i) -> i + | ShortArgumentPartialPos(_, i) -> i | ArgumentPos _ -> 0 member x.IsEndOf(argv: string array) = match x with | ArgumentPos x -> x >= argv.Length - | ShortArgumentPartialPos (x, innerPos) -> + | ShortArgumentPartialPos(x, innerPos) -> if x >= argv.Length then true else if x = argv.Length - 1 then @@ -100,7 +100,7 @@ type ArgumentStreamPosition = ShortArgumentPartialPos(x + 1, 1) else ArgumentPos(argv.Length) - | ShortArgumentPartialPos (x, i) -> + | ShortArgumentPartialPos(x, i) -> let c = argv.[x] if i + 1 < c.Length then @@ -121,7 +121,7 @@ type ArgumentStreamPosition = let res = match x with | ArgumentPos x - | ShortArgumentPartialPos (x, _) -> + | ShortArgumentPartialPos(x, _) -> if x + 1 < argv.Length then let next = argv.[x + 1] @@ -187,7 +187,7 @@ type ArgumentStream<'TUserState> private (argv: string array, initState: 'TUserS let current () = match pos with | ArgumentPos x -> if x < argv.Length then Some argv.[x] else None - | ShortArgumentPartialPos (x, i) -> + | ShortArgumentPartialPos(x, i) -> if x < argv.Length then Some(sprintf "-%c" argv.[x].[i]) else @@ -195,15 +195,12 @@ type ArgumentStream<'TUserState> private (argv: string array, initState: 'TUserS let currentFull () = match pos with - | ShortArgumentPartialPos (x, _) + | ShortArgumentPartialPos(x, _) | ArgumentPos x -> if x < argv.Length then Some argv.[x] else None interface IArgumentStream<'TUserState> with member x.CurrentState = - { Pos = pos - StateTag = stateTag - UserState = state } - :> IArgumentStreamState<'TUserState> + { Pos = pos; StateTag = stateTag; UserState = state } :> IArgumentStreamState<'TUserState> member x.Position = pos @@ -266,11 +263,11 @@ type ArgumentStream<'TUserState> private (argv: string array, initState: 'TUserS module ArgumentStream = let create (argv: string array) (initState: 'TUserState) = - ArgumentStream<'TUserState>.Create (argv, initState) :> IArgumentStream<_> + ArgumentStream<'TUserState>.Create(argv, initState) :> IArgumentStream<_> let clone (stream: IArgumentStream<_>) = let clone = - ArgumentStream<'TUserState>.Create (stream.Argv, stream.UserState) :> IArgumentStream<_> + ArgumentStream<'TUserState>.Create(stream.Argv, stream.UserState) :> IArgumentStream<_> clone.RestoreState( { Pos = stream.Position @@ -293,6 +290,7 @@ module ArgumentStream = { new IArgumentStream<'un> with member x.CurrentState = let innerState = inner.CurrentState + { Inner = innerState; State = newState } :> IArgumentStreamState<'un> member x.Position = inner.Position @@ -500,7 +498,7 @@ module ArgParser = Reply(reply.Status, error) else match resultForEmptySequence with - | Some _ (* if we bind f here, fsc won't be able to inline it *) when + | Some _ (* if we bind f here, fsc won't be able to inline it *) when reply.Status = Error && stateTag = stream.StateTag -> Reply( @@ -513,16 +511,14 @@ module ArgParser = | _ -> Reply(reply.Status, reply.Error) let many p = - Inline.Many((fun x -> [ x ]), (fun xs x -> x :: xs), List.rev, p, resultForEmptySequence = fun () -> []) + Inline.Many((fun x -> [ x ]), (fun xs x -> x :: xs), List.rev, p, resultForEmptySequence = (fun () -> [])) let many1 p = Inline.Many((fun x -> [ x ]), (fun xs x -> x :: xs), List.rev, p) let pseq (ps: seq>) : ArgumentParser<_, _> = Seq.fold (>>.) (preturn Map.empty) ps - type internal UnorderedState<'u, 'a> = - { InnerState: 'u - AppliedParsers: int list } + type internal UnorderedState<'u, 'a> = { InnerState: 'u; AppliedParsers: int list } let internal mapParserToUnorderedState i (p: ArgumentParser<'u, _>) : ArgumentParser, _> = fun innerStream -> @@ -536,7 +532,8 @@ module ArgParser = if reply.Status = Ok then innerStream.UserState <- - { innerStream.UserState with AppliedParsers = i :: innerStream.UserState.AppliedParsers } + { innerStream.UserState with + AppliedParsers = i :: innerStream.UserState.AppliedParsers } reply @@ -544,8 +541,7 @@ module ArgParser = fun (stream: IArgumentStream<_>) -> let newStream = ArgumentStream.map - { InnerState = stream.UserState - AppliedParsers = [] } + { InnerState = stream.UserState; AppliedParsers = [] } (fun _ s -> s.InnerState) stream @@ -648,18 +644,18 @@ module ArgParser = | None, _ | Some DocoptResult.NoResult, _ -> Map.add key newItem map | _, DocoptResult.NoResult -> map - | Some (DocoptResult.Argument arg1), DocoptResult.Argument arg2 -> + | Some(DocoptResult.Argument arg1), DocoptResult.Argument arg2 -> Map.add key (DocoptResult.Arguments [ arg1; arg2 ]) map - | Some (DocoptResult.Argument arg1), DocoptResult.Arguments argList -> + | Some(DocoptResult.Argument arg1), DocoptResult.Arguments argList -> Map.add key (DocoptResult.Arguments(arg1 :: argList)) map - | Some (DocoptResult.Arguments argList1), DocoptResult.Argument arg2 -> + | Some(DocoptResult.Arguments argList1), DocoptResult.Argument arg2 -> Map.add key (DocoptResult.Arguments(argList1 @ [ arg2 ])) map - | Some (DocoptResult.Arguments argList1), DocoptResult.Arguments argList2 -> + | Some(DocoptResult.Arguments argList1), DocoptResult.Arguments argList2 -> Map.add key (DocoptResult.Arguments(argList1 @ argList2)) map - | Some (DocoptResult.Flag), DocoptResult.Flag -> Map.add key (DocoptResult.Flags 2) map - | Some (DocoptResult.Flags n1), DocoptResult.Flag -> Map.add key (DocoptResult.Flags(n1 + 1)) map - | Some (DocoptResult.Flag), DocoptResult.Flags n2 -> Map.add key (DocoptResult.Flags(n2 + 1)) map - | Some (DocoptResult.Flags n1), DocoptResult.Flags n2 -> Map.add key (DocoptResult.Flags(n1 + n2)) map + | Some(DocoptResult.Flag), DocoptResult.Flag -> Map.add key (DocoptResult.Flags 2) map + | Some(DocoptResult.Flags n1), DocoptResult.Flag -> Map.add key (DocoptResult.Flags(n1 + 1)) map + | Some(DocoptResult.Flag), DocoptResult.Flags n2 -> Map.add key (DocoptResult.Flags(n2 + 1)) map + | Some(DocoptResult.Flags n1), DocoptResult.Flags n2 -> Map.add key (DocoptResult.Flags(n1 + n2)) map | Some v, _ -> failwithf "Cannot add value %O as %s -> %O already exists in the result map" newItem key v let saveInMap key f = @@ -703,7 +699,7 @@ module ArgParser = if flag.HasArgument then let chooseCmd arg = match arg with - | Some (arg: string) when arg.StartsWith(flag.FullLong + "=") -> + | Some(arg: string) when arg.StartsWith(flag.FullLong + "=") -> Some(arg.Substring(flag.FullLong.Length + 1)) | _ -> None @@ -728,13 +724,13 @@ module ArgParser = // When we have a argument we know we can consume the complete argument let chooseCmd (stream: IArgumentStream<_>) = match stream.Peek(), stream.PeekFull() with - | Some (arg: string), Some (fullarg) when arg.StartsWith flag.FullShort -> + | Some(arg: string), Some(fullarg) when arg.StartsWith flag.FullShort -> let oldPos = stream.Position stream.SkipFull() let result = match oldPos with - | ShortArgumentPartialPos (_, i) when i + 1 < fullarg.Length -> + | ShortArgumentPartialPos(_, i) when i + 1 < fullarg.Length -> // Parameter for short switch is in current argument Some(fullarg.Substring(i + 1)) | _ -> None @@ -760,7 +756,7 @@ module ArgParser = else let chooseCmd arg = match arg with - | Some (arg: string) when arg = flag.FullShort -> Some arg + | Some(arg: string) when arg = flag.FullShort -> Some arg | _ -> None chooseParser (sprintf "ShortFlag '%s'" flag.FullShort) chooseCmd @@ -789,7 +785,7 @@ module ArgParser = let p = match ast with | UsageAst.Eps -> preturn Map.empty - | UsageAst.Ano (_, o') -> + | UsageAst.Ano(_, o') -> // Annotations are always optional pOptions true o' <|> preturn Map.empty //pzero "Option annotation is not supported yet" @@ -798,17 +794,17 @@ module ArgParser = //o'. //pzero "Short options are not supported yet" | UsageAst.Lop o' -> pOption true o' - | UsageAst.Sqb (UsageAst.Seq asts') when ast.ContainsOnlyOptions -> + | UsageAst.Sqb(UsageAst.Seq asts') when ast.ContainsOnlyOptions -> asts' |> Seq.map getParser |> Seq.toList |> punorderedseq false true >>= updateUserState (fun _ state -> state) - | UsageAst.Sqb (UsageAst.Sop o') -> pOptions true o' <|> preturn Map.empty + | UsageAst.Sqb(UsageAst.Sop o') -> pOptions true o' <|> preturn Map.empty | UsageAst.Sqb ast' -> getParser ast' <|> preturn Map.empty | UsageAst.Arg name' -> parg name' >>= saveInMap (name') (DocoptResult.Argument) | UsageAst.XorEmpty -> preturn Map.empty - | UsageAst.Xor (l', r') -> choiceBest [ getParser l'; getParser r' ] + | UsageAst.Xor(l', r') -> choiceBest [ getParser l'; getParser r' ] | UsageAst.Seq asts' when ast.ContainsOnlyOptions -> asts' |> Seq.map getParser @@ -818,7 +814,7 @@ module ArgParser = | UsageAst.Req ast' -> getParser ast' | UsageAst.Seq asts' -> asts' |> Seq.map getParser |> pseq | UsageAst.Cmd cmd' -> pcmd cmd' >>= saveInMap cmd' (fun _ -> DocoptResult.Flag) - | UsageAst.Ell (UsageAst.Sqb ast') -> + | UsageAst.Ell(UsageAst.Sqb ast') -> // Allow zero matches many (getParser ast') >>= updateUserState (fun _ state -> state) | UsageAst.Ell ast' -> @@ -865,16 +861,18 @@ type UsageParser(usageStrings': string array, sections: (string * SafeOptions) l UsageAstBuilder.Arg(arg') elif (match last'.Content with - | Some (UsageAstBuilder.Sop opts) -> opts.Last.HasArgument + | Some(UsageAstBuilder.Sop opts) -> opts.Last.HasArgument | _ -> false) || (match last'.Content with - | Some (UsageAstBuilder.Lop opt) -> opt.HasArgument + | Some(UsageAstBuilder.Lop opt) -> opt.HasArgument | _ -> false) then UsageAstBuilder.Eps else UsageAstBuilder.Arg(arg') - |> UsageAstCell.FromBuilder in pupperArg <|> plowerArg >>= updateUserState filterArg + |> UsageAstCell.FromBuilder in + + pupperArg <|> plowerArg >>= updateUserState filterArg let pano (title, so: SafeOptions) = skipString (sprintf "[%s]" title) @@ -907,7 +905,7 @@ type UsageParser(usageStrings': string array, sections: (string * SafeOptions) l UsageAstBuilder.Eps else match last'.Content with - | Some (UsageAstBuilder.Sop list) -> + | Some(UsageAstBuilder.Sop list) -> last'.Content <- Some(UsageAstBuilder.Sop(list.AddRange(sops |> List.ofSeq))) UsageAstBuilder.Eps | _ -> UsageAstBuilder.Sop(SafeOptions(sops |> Seq.toList)) @@ -975,7 +973,7 @@ type UsageParser(usageStrings': string array, sections: (string * SafeOptions) l let makeEll (ast': UsageAstCell) = match ast'.Content with - | Some (UsageAstBuilder.Seq seq) -> + | Some(UsageAstBuilder.Seq seq) -> let cell = seq |> List.last cell.Content <- @@ -1019,8 +1017,8 @@ type UsageParser(usageStrings': string array, sections: (string * SafeOptions) l let line = line.Substring(index) in match runParserOnString pusageLine { Content = None } "" line with - | Success (ast, _, _) -> ast.Build() - | Failure (err, _, _) -> raise (UsageException(err)) + | Success(ast, _, _) -> ast.Build() + | Failure(err, _, _) -> raise (UsageException(err)) } do diff --git a/src/app/Fake.Core.Environment/Environment.fs b/src/app/Fake.Core.Environment/Environment.fs index c8b06355606..03da98445e0 100644 --- a/src/app/Fake.Core.Environment/Environment.fs +++ b/src/app/Fake.Core.Environment/Environment.fs @@ -415,7 +415,6 @@ module Environment = let getNuGetPackagesCacheFolder () = nugetPackagesFolder.Value - #if !NETSTANDARD [] /// @@ -426,8 +425,7 @@ module Environment = try let matches = - Registry - .LocalMachine + Registry.LocalMachine .OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP") .GetSubKeyNames() |> Seq.filter (fun keyname -> Regex.IsMatch(keyname, @"^v\d")) @@ -489,7 +487,8 @@ module Environment = AgentVersion = sprintf "%A" - ((System.Reflection.Assembly.GetAssembly(typedefof)).GetName() + ((System.Reflection.Assembly.GetAssembly(typedefof)) + .GetName() .Version) DriveInfo = getDrivesInfo () } #endif diff --git a/src/app/Fake.Core.Process/CmdLineParsing.fs b/src/app/Fake.Core.Process/CmdLineParsing.fs index 727a552de2b..21fc3d8217e 100644 --- a/src/app/Fake.Core.Process/CmdLineParsing.fs +++ b/src/app/Fake.Core.Process/CmdLineParsing.fs @@ -185,8 +185,7 @@ type Arguments = /// Create a new arguments object from the given list of arguments static member OfArgs(args: string seq) = - { Args = args |> Seq.toArray - Original = None } + { Args = args |> Seq.toArray; Original = None } /// Create a new arguments object from a given startinfo-conforming-escaped command line string. /// Same as `OfWindowsCommandLine`. @@ -280,7 +279,6 @@ module Arguments = /// Create a arguments instance from a list. let ofList (a: string list) = - { Args = a |> Seq.toArray - Original = None } + { Args = a |> Seq.toArray; Original = None } #endif diff --git a/src/app/Fake.Core.Process/CreateProcess.fs b/src/app/Fake.Core.Process/CreateProcess.fs index a822a5bad26..f8a9fc1a902 100644 --- a/src/app/Fake.Core.Process/CreateProcess.fs +++ b/src/app/Fake.Core.Process/CreateProcess.fs @@ -119,9 +119,7 @@ module CreateProcess = async { let! raw = Async.AwaitTaskWithoutAggregate t - return - { ExitCode = raw.RawExitCode - Result = () } + return { ExitCode = raw.RawExitCode; Result = () } } } /// @@ -239,7 +237,7 @@ module CreateProcess = let internal interceptStreamFallback onInherit target (s: StreamSpecification) = match s with | Inherit -> onInherit () - | UseStream (close, stream) -> + | UseStream(close, stream) -> let combined = Stream.CombineWrite(stream, target) UseStream(close, combined) | CreatePipe pipe -> CreatePipe(StreamRef.Map (fun s -> Stream.InterceptStream(s, target)) pipe) @@ -308,7 +306,7 @@ module CreateProcess = InternalCommand = match c.Command with | ShellCommand _s -> failwith "Expected RawCommand" - | RawCommand (_, c) -> RawCommand(newFilePath, c) } + | RawCommand(_, c) -> RawCommand(newFilePath, c) } /// /// Map the file-path according to the given function. @@ -322,7 +320,7 @@ module CreateProcess = f ( match c.Command with | ShellCommand _s -> failwith "Expected RawCommand" - | RawCommand (file, _) -> f file + | RawCommand(file, _) -> f file ) ) @@ -493,7 +491,8 @@ module CreateProcess = /// The environment variable value /// The create process instance let setEnvironmentVariable envKey (envVar: string) (c: CreateProcess<_>) = - { c with InternalEnvironment = getEnvironmentMap c |> IMap.add envKey envVar |> Some } + { c with + InternalEnvironment = getEnvironmentMap c |> IMap.add envKey envVar |> Some } /// /// Set the standard output stream. @@ -502,7 +501,8 @@ module CreateProcess = /// The standard output to use /// The create process instance let withStandardOutput stdOut (c: CreateProcess<_>) = - { c with Streams = { c.Streams with StandardOutput = stdOut } } + { c with + Streams = { c.Streams with StandardOutput = stdOut } } /// /// Set the standard error stream. @@ -511,7 +511,8 @@ module CreateProcess = /// The standard error to use /// The create process instance let withStandardError stdErr (c: CreateProcess<_>) = - { c with Streams = { c.Streams with StandardError = stdErr } } + { c with + Streams = { c.Streams with StandardError = stdErr } } /// /// Set the standard input stream. @@ -520,7 +521,8 @@ module CreateProcess = /// The standard input to use /// The create process instance let withStandardInput stdIn (c: CreateProcess<_>) = - { c with Streams = { c.Streams with StandardInput = stdIn } } + { c with + Streams = { c.Streams with StandardInput = stdIn } } /// /// Map the current result to a new type. @@ -543,10 +545,7 @@ module CreateProcess = /// /// Function to run result map through let mapResult f (c: CreateProcess>) = - c - |> map (fun r -> - { ExitCode = r.ExitCode - Result = f r.Result }) + c |> map (fun r -> { ExitCode = r.ExitCode; Result = f r.Result }) /// /// Starts redirecting the output streams and collects all data at the end. @@ -575,11 +574,10 @@ module CreateProcess = errMem.Position <- 0L let stdErr = (new StreamReader(errMem)).ReadToEnd() let stdOut = (new StreamReader(outMem)).ReadToEnd() + let r = { Output = stdOut; Error = stdErr } - return - { ExitCode = exitCode.RawExitCode - Result = r } + return { ExitCode = exitCode.RawExitCode; Result = r } }) (fun (outMem, errMem) -> outMem.Dispose() @@ -822,9 +820,7 @@ module CreateProcess = data) - type internal TimeoutState = - { Stopwatch: Stopwatch - mutable HasExited: bool } + type internal TimeoutState = { Stopwatch: Stopwatch; mutable HasExited: bool } /// /// Set the given timeout, kills the process after the specified timespan @@ -835,9 +831,7 @@ module CreateProcess = let withTimeout (timeout: TimeSpan) (c: CreateProcess<_>) = c |> appendSimpleFuncs - (fun _ -> - { Stopwatch = Stopwatch.StartNew() - HasExited = false }) + (fun _ -> { Stopwatch = Stopwatch.StartNew(); HasExited = false }) (fun state proc -> state.Stopwatch.Restart() diff --git a/src/app/Fake.Core.Process/CreateProcessExt.fs b/src/app/Fake.Core.Process/CreateProcessExt.fs index 13ea4a7f84b..e983aa60c02 100644 --- a/src/app/Fake.Core.Process/CreateProcessExt.fs +++ b/src/app/Fake.Core.Process/CreateProcessExt.fs @@ -26,9 +26,10 @@ module CreateProcessExt = /// let withFramework (c: CreateProcess<_>) = match Environment.isWindows, c.Command, Process.monoPath with - | false, RawCommand (file, args), Some monoPath when file.ToLowerInvariant().EndsWith(".exe") -> - { c with InternalCommand = RawCommand(monoPath, Arguments.withPrefix [ "--debug"; file ] args) } - | false, RawCommand (file, _args), _ when file.ToLowerInvariant().EndsWith(".exe") -> + | false, RawCommand(file, args), Some monoPath when file.ToLowerInvariant().EndsWith(".exe") -> + { c with + InternalCommand = RawCommand(monoPath, Arguments.withPrefix [ "--debug"; file ] args) } + | false, RawCommand(file, _args), _ when file.ToLowerInvariant().EndsWith(".exe") -> failwithf "trying to start a .NET process on a non-windows platform, but mono could not be found. Try to set the MONO environment variable or add mono to the PATH." | _ -> c diff --git a/src/app/Fake.Core.Process/InternalStreams.fs b/src/app/Fake.Core.Process/InternalStreams.fs index a5ca181c897..da58d39a253 100644 --- a/src/app/Fake.Core.Process/InternalStreams.fs +++ b/src/app/Fake.Core.Process/InternalStreams.fs @@ -158,7 +158,7 @@ module internal InternalStreams = let! msg = inbox.Receive() match msg with - | Enqueue (item, reply) -> + | Enqueue(item, reply) -> try if waitingQueue.Count > 0 then let waiting = waitingQueue.Dequeue() diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index b699dd7c8c6..8fb0b66c9b4 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -48,8 +48,7 @@ type ProcessResult = | _ -> None) static member New exitCode results = - { ExitCode = exitCode - Results = results } + { ExitCode = exitCode; Results = results } module private ProcStartInfoData = let defaultEnvVar = "__FAKE_CHECK_USER_ERROR" @@ -204,7 +203,7 @@ type ProcStartInfo = x.Environment |> Map.remove defaultEnvVar - |> Map.iter (fun var key -> p.Environment[ var ] <- key) + |> Map.iter (fun var key -> p.Environment[var] <- key) #if FX_ERROR_DIALOG if p.ErrorDialog then @@ -580,6 +579,7 @@ module Process = |> Async.Start stateNeedsDispose <- false + return { Result = output; Raw = exitCode } finally if stateNeedsDispose && not (isNull state) then diff --git a/src/app/Fake.Core.Process/RawProc.fs b/src/app/Fake.Core.Process/RawProc.fs index d45aac01440..244b1fbfeca 100644 --- a/src/app/Fake.Core.Process/RawProc.fs +++ b/src/app/Fake.Core.Process/RawProc.fs @@ -63,17 +63,17 @@ type Command = member x.CommandLine = match x with | ShellCommand s -> s - | RawCommand (f, arg) -> sprintf "%s %s" f arg.ToWindowsCommandLine + | RawCommand(f, arg) -> sprintf "%s %s" f arg.ToWindowsCommandLine member x.Arguments = match x with | ShellCommand _ -> raise <| NotImplementedException "Cannot retrieve Arguments for ShellCommand" - | RawCommand (_, arg) -> arg + | RawCommand(_, arg) -> arg member x.Executable = match x with | ShellCommand _ -> raise <| NotImplementedException "Cannot retrieve Executable for ShellCommand" - | RawCommand (f, _) -> f + | RawCommand(f, _) -> f /// /// Represents basically an "out" parameter, allows to retrieve a value after a certain point in time. @@ -163,12 +163,12 @@ type internal RawCreateProcess = p.UseShellExecute <- true p.FileName <- s p.Arguments <- null - | RawCommand (filename, args) -> + | RawCommand(filename, args) -> p.UseShellExecute <- false p.FileName <- filename p.Arguments <- args.ToStartInfo - let setEnv key var = p.Environment[ key ] <- var + let setEnv key var = p.Environment[key] <- var x.Environment |> Option.iter (fun env -> @@ -254,7 +254,7 @@ module internal RawProc = async { match parameter with | Inherit -> return failwithf "Unexpected value" - | UseStream (shouldClose, stream) -> + | UseStream(shouldClose, stream) -> if isInputStream then do! stream.CopyToAsync(processStream, 81920, tok.Token) diff --git a/src/app/Fake.Core.ReleaseNotes/Changelog.fs b/src/app/Fake.Core.ReleaseNotes/Changelog.fs index c63a0a06a80..d18ff417c9d 100644 --- a/src/app/Fake.Core.ReleaseNotes/Changelog.fs +++ b/src/app/Fake.Core.ReleaseNotes/Changelog.fs @@ -77,9 +77,7 @@ module Changelog = /// /// Holds cleared and original text versions of log entry /// - type ChangeText = - { CleanedText: string - OriginalText: string option } + type ChangeText = { CleanedText: string; OriginalText: string option } /// Type of change on log entry type Change = @@ -106,7 +104,7 @@ module Changelog = | Removed s -> sprintf "Removed: %s" s.CleanedText | Fixed s -> sprintf "Fixed: %s" s.CleanedText | Security s -> sprintf "Security: %s" s.CleanedText - | Custom (h, s) -> sprintf "%s: %s" h s.CleanedText + | Custom(h, s) -> sprintf "%s: %s" h s.CleanedText /// Create a new change type changelog entry static member New(header: string, line: string) : Change = @@ -140,7 +138,7 @@ module Changelog = | Removed c -> "\n### Removed", (bullet c) | Fixed c -> "\n### Fixed", (bullet c) | Security c -> "\n### Security", (bullet c) - | Custom (h, c) -> (sprintf "\n### %s" h), (bullet c) + | Custom(h, c) -> (sprintf "\n### %s" h), (bullet c) let private makeDescriptionText text = match text with @@ -231,17 +229,11 @@ module Changelog = /// Create a new unreleased changelog entry static member New(description, changes) = match description with - | Some _ -> - Some - { Description = description - Changes = changes } + | Some _ -> Some { Description = description; Changes = changes } | None -> match changes with | [] -> None - | _ -> - Some - { Description = description - Changes = changes } + | _ -> Some { Description = description; Changes = changes } let internal nugetRegex = String.getRegEx @"([0-9]+.)+[0-9]+(-[a-zA-Z]+\d*)?(.[0-9]+)?" @@ -466,7 +458,7 @@ module Changelog = let rec categoryLoop (changes: Change list) (text: string list) : Change list = match findNextCategoryBlock text with - | Some (header, (changeLines, rest)) -> + | Some(header, (changeLines, rest)) -> categoryLoop ((changeLines |> List.rev |> List.map (fun line -> Change.New(header, line))) |> List.append changes) @@ -475,7 +467,7 @@ module Changelog = let rec loop changeLogEntries text = match findNextChangesBlock text with - | Some (header, (changes, rest)) -> + | Some(header, (changes, rest)) -> let assemblyVer, nugetVer = parseVersions header let date = parseDate header let changeLines = categoryLoop [] (changes |> List.rev) @@ -511,7 +503,7 @@ module Changelog = let unreleased = match findUnreleasedBlock text with - | Some (changes, _) -> + | Some(changes, _) -> let unreleasedChanges = categoryLoop [] (changes |> List.rev) let description = diff --git a/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs b/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs index bdb238efb01..a5db86a576a 100644 --- a/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs +++ b/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs @@ -184,7 +184,7 @@ module ReleaseNotes = let rec loop releaseNotes text = match findNextNotesBlock text with - | Some (header, (notes, rest)) -> + | Some(header, (notes, rest)) -> let assemblyVer, nugetVer = parseVersions header let date = parseDate header diff --git a/src/app/Fake.Core.SemVer/SemVer.fs b/src/app/Fake.Core.SemVer/SemVer.fs index 834ae8b903c..3cb5a7b2ad0 100644 --- a/src/app/Fake.Core.SemVer/SemVer.fs +++ b/src/app/Fake.Core.SemVer/SemVer.fs @@ -86,8 +86,8 @@ type PreRelease = else let getName fromList = match fromList with - | AlphaNumeric (a) :: _ -> a - | _ :: AlphaNumeric (a) :: _ -> a // fallback to 2nd + | AlphaNumeric(a) :: _ -> a + | _ :: AlphaNumeric(a) :: _ -> a // fallback to 2nd | _ -> "" let parse (segment: string) = @@ -115,10 +115,7 @@ type PreRelease = let list = multiple |> Array.map parse |> List.ofArray getName list, list - Some - { Origin = str - Name = name - Values = values } + Some { Origin = str; Name = name; Values = values } member x.Equals(y) = x.Origin = y.Origin diff --git a/src/app/Fake.Core.String/FakePrintf.fs b/src/app/Fake.Core.String/FakePrintf.fs index d4e58446d11..2395571eb97 100644 --- a/src/app/Fake.Core.String/FakePrintf.fs +++ b/src/app/Fake.Core.String/FakePrintf.fs @@ -50,7 +50,6 @@ type internal FormatOptions = ShowIEnumerable = true } - type internal PrintfFormat<'Printer, 'State, 'Residue, 'Result>(value: string) = member x.Value = value @@ -1023,11 +1022,11 @@ module internal PrintfImpl = | 'g' | 'G' -> basicFloatToString ty spec | 'A' -> - let mi = typeof.GetMethod ("GenericToString", NonPublicStatics) + let mi = typeof.GetMethod("GenericToString", NonPublicStatics) let mi = mi.MakeGenericMethod(ty) mi.Invoke(null, [| box spec |]) | 'O' -> - let mi = typeof.GetMethod ("ObjectToString", NonPublicStatics) + let mi = typeof.GetMethod("ObjectToString", NonPublicStatics) let mi = mi.MakeGenericMethod(ty) mi.Invoke(null, [| box spec |]) | _ -> raise (ArgumentException(sprintf "Bad format specifier:%c" spec.TypeChar)) @@ -1133,7 +1132,8 @@ module internal PrintfImpl = let buildSpecialChained (spec: FormatSpecifier, argTys: Type[], prefix: string, tail: obj, retTy) = if spec.TypeChar = 'a' then let mi = - typeof>.GetMethod ("LittleAChained", NonPublicStatics) + typeof> + .GetMethod("LittleAChained", NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1144,7 +1144,7 @@ module internal PrintfImpl = mi.Invoke(null, args) elif spec.TypeChar = 't' then let mi = - typeof>.GetMethod ("TChained", NonPublicStatics) + typeof>.GetMethod("TChained", NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1168,7 +1168,7 @@ module internal PrintfImpl = "StarChained" let name = prefix + (string n) - typeof>.GetMethod (name, NonPublicStatics) + typeof>.GetMethod(name, NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1187,7 +1187,8 @@ module internal PrintfImpl = let buildSpecialFinal (spec: FormatSpecifier, argTys: Type[], prefix: string, suffix: string) = if spec.TypeChar = 'a' then let mi = - typeof>.GetMethod ("LittleAFinal", NonPublicStatics) + typeof> + .GetMethod("LittleAFinal", NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1197,7 +1198,7 @@ module internal PrintfImpl = mi.Invoke(null, args) elif spec.TypeChar = 't' then let mi = - typeof>.GetMethod ("TFinal", NonPublicStatics) + typeof>.GetMethod("TFinal", NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1220,7 +1221,7 @@ module internal PrintfImpl = "StarFinal" let name = prefix + (string n) - typeof>.GetMethod (name, NonPublicStatics) + typeof>.GetMethod(name, NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1239,8 +1240,8 @@ module internal PrintfImpl = let buildPlainFinal (args: obj[], argTypes: Type[]) = let mi = - typeof>.GetMethod - ("Final" + (let x = argTypes.Length in x.ToString()), NonPublicStatics) + typeof> + .GetMethod("Final" + (let x = argTypes.Length in x.ToString()), NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1250,8 +1251,8 @@ module internal PrintfImpl = let buildPlainChained (args: obj[], argTypes: Type[]) = let mi = - typeof>.GetMethod - ("Chained" + (let x = (argTypes.Length - 1) in x.ToString()), NonPublicStatics) + typeof> + .GetMethod("Chained" + (let x = (argTypes.Length - 1) in x.ToString()), NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else diff --git a/src/app/Fake.Core.Target/Target.fs b/src/app/Fake.Core.Target/Target.fs index dde9652f7a5..ceb3733c8e5 100644 --- a/src/app/Fake.Core.Target/Target.fs +++ b/src/app/Fake.Core.Target/Target.fs @@ -72,9 +72,7 @@ and [] TargetContext = | Some er -> Some(er, tres.Target) | None -> None) -and [] TargetParameter = - { TargetInfo: Target - Context: TargetContext } +and [] TargetParameter = { TargetInfo: Target; Context: TargetContext } /// [omit] and [] Target = @@ -95,9 +93,7 @@ type internal DeclarationInfo = Column: int ErrorDetail: string } -type internal Dependency = - { Name: string - Declaration: DeclarationInfo } +type internal Dependency = { Name: string; Declaration: DeclarationInfo } [] [] @@ -132,17 +128,12 @@ type BuildFailedException = val private info: TargetContext option inherit Exception - new(msg: string, inner: exn) = - { inherit Exception(msg, inner) - info = None } + new(msg: string, inner: exn) = { inherit Exception(msg, inner); info = None } - new(info: TargetContext, msg: string, inner: exn) = - { inherit Exception(msg, inner) - info = Some info } + new(info: TargetContext, msg: string, inner: exn) = { inherit Exception(msg, inner); info = Some info } #if !NETSTANDARD1_6 new(info: System.Runtime.Serialization.SerializationInfo, context: System.Runtime.Serialization.StreamingContext) = - { inherit Exception(info, context) - info = None } + { inherit Exception(info, context); info = None } #endif member x.Info = x.info @@ -283,7 +274,7 @@ module Target = /// The description of the next target let description text = match getLastDescription () with - | Some (v: string) -> + | Some(v: string) -> failwithf "You can't set the description for a target twice. There is already a description: %A" v | None -> setLastDescription text @@ -368,9 +359,7 @@ module Target = if not context.IsRunningFinalTargets then context.CancellationToken.ThrowIfCancellationRequested() - target.Function - { TargetInfo = target - Context = context } + target.Function { TargetInfo = target; Context = context } None with e -> @@ -396,7 +385,8 @@ module Target = else t.MarkSuccess() - { context with PreviousTargets = context.PreviousTargets @ [ result ] } + { context with + PreviousTargets = context.PreviousTargets @ [ result ] } /// /// This simply runs the function of a target without doing anything (like tracing, stop watching or adding @@ -481,10 +471,7 @@ module Target = getTargetDict().[targetName] <- { target with - Dependencies = - { Name = dependentTargetName - Declaration = decl } - :: target.Dependencies + Dependencies = { Name = dependentTargetName; Declaration = decl } :: target.Dependencies SoftDependencies = target.SoftDependencies |> List.filter (fun d -> @@ -512,10 +499,7 @@ module Target = getTargetDict().[targetName] <- { target with - SoftDependencies = - { Name = dependentTargetName - Declaration = decl } - :: target.SoftDependencies } + SoftDependencies = { Name = dependentTargetName; Declaration = decl } :: target.SoftDependencies } /// /// Adds the dependency to the list of dependencies. @@ -917,7 +901,8 @@ module Target = targets |> List.filter (fun tres -> not (known.ContainsKey(String.toLower tres.Target.Name))) - { ctx1 with PreviousTargets = ctx1.PreviousTargets @ filterKnown ctx2.PreviousTargets } + { ctx1 with + PreviousTargets = ctx1.PreviousTargets @ filterKnown ctx2.PreviousTargets } // Centralized handling of target context and next target logic... [] @@ -945,7 +930,7 @@ module Target = let! msg = inbox.Receive() match msg with - | GetNextTarget (newCtx, reply) -> + | GetNextTarget(newCtx, reply) -> let failwithf pf = // handle reply before throwing. let tcs = TaskCompletionSource() @@ -1070,7 +1055,7 @@ module Target = let! msg = inbox.Receive() match msg with - | GetNextTarget (_, reply) -> + | GetNextTarget(_, reply) -> reply.Reply(async { return raise <| exn ("mailbox failed", e) }) } @@ -1437,7 +1422,7 @@ module Target = writeInfoFile file None | NoAction -> None - | ExecuteTarget (target, arguments, parallelJobs, singleTarget) -> + | ExecuteTarget(target, arguments, parallelJobs, singleTarget) -> if not allowAdditionalArgs && arguments <> [] then failwithf "The following arguments could not be parsed: %A\nTo forward arguments to your targets you need to use \nTarget.runOrDefaultWithArguments instead of Target.runOrDefault" @@ -1513,7 +1498,7 @@ module Target = /// let getArguments () = initAndProcess (function - | ExecuteTarget (_, args, _, _) -> args |> List.toArray |> Some + | ExecuteTarget(_, args, _, _) -> args |> List.toArray |> Some | _ -> None) /// diff --git a/src/app/Fake.Core.Trace/TraceListener.fs b/src/app/Fake.Core.Trace/TraceListener.fs index ae68dcc4a9d..2134f2b1c91 100644 --- a/src/app/Fake.Core.Trace/TraceListener.fs +++ b/src/app/Fake.Core.Trace/TraceListener.fs @@ -25,7 +25,7 @@ type KnownTags = | Compilation n | TestSuite n | Test n - | Other (_, n) -> n + | Other(_, n) -> n member x.Type = match x with @@ -36,7 +36,7 @@ type KnownTags = | Compilation _ -> "compilation" | TestSuite _ -> "testsuite" | Test _ -> "test" - | Other (t, _) -> t + | Other(t, _) -> t // Note: Adding new cases to this type is not considered a breaking change! /// The list of DotNet coverage tools supported @@ -126,9 +126,9 @@ type TestStatus = module TestStatus = let inline mapMessage f (t: TestStatus) = match t with - | TestStatus.Failed (message, details, Some (expected, actual)) -> + | TestStatus.Failed(message, details, Some(expected, actual)) -> TestStatus.Failed(f message, f details, Some(f expected, f actual)) - | TestStatus.Failed (message, details, None) -> TestStatus.Failed(f message, f details, None) + | TestStatus.Failed(message, details, None) -> TestStatus.Failed(f message, f details, None) | _ -> t // Note: Adding new cases to this type is not considered a breaking change! @@ -162,8 +162,8 @@ type TraceData = match x with | ImportantMessage _ | ErrorMessage _ -> Some true - | LogMessage (_, newLine) - | TraceMessage (_, newLine) -> Some newLine + | LogMessage(_, newLine) + | TraceMessage(_, newLine) -> Some newLine | BuildNumber _ | TestStatus _ | TestOutput _ @@ -176,9 +176,9 @@ type TraceData = match x with | ImportantMessage text | ErrorMessage text - | LogMessage (text, _) - | TraceMessage (text, _) - | BuildState (_, Some text) -> Some text + | LogMessage(text, _) + | TraceMessage(text, _) + | BuildState(_, Some text) -> Some text | BuildNumber _ | TestStatus _ | TestOutput _ @@ -200,14 +200,14 @@ module TraceData = match t with | TraceData.ImportantMessage text -> TraceData.ImportantMessage(f text) | TraceData.ErrorMessage text -> TraceData.ErrorMessage(f text) - | TraceData.LogMessage (text, d) -> TraceData.LogMessage(f text, d) - | TraceData.TraceMessage (text, d) -> TraceData.TraceMessage(f text, d) - | TraceData.TestStatus (testName, status) -> TraceData.TestStatus(testName, TestStatus.mapMessage f status) - | TraceData.TestOutput (testName, out, err) -> TraceData.TestOutput(testName, f out, f err) - | TraceData.OpenTag (tag, Some d) -> TraceData.OpenTag((mapKnownTags f tag), Some(f d)) - | TraceData.OpenTag (tag, None) -> TraceData.OpenTag((mapKnownTags f tag), None) - | TraceData.CloseTag (tag, time, status) -> TraceData.CloseTag((mapKnownTags f tag), time, status) - | TraceData.BuildState (tag, Some message) -> TraceData.BuildState(tag, Some(f message)) + | TraceData.LogMessage(text, d) -> TraceData.LogMessage(f text, d) + | TraceData.TraceMessage(text, d) -> TraceData.TraceMessage(f text, d) + | TraceData.TestStatus(testName, status) -> TraceData.TestStatus(testName, TestStatus.mapMessage f status) + | TraceData.TestOutput(testName, out, err) -> TraceData.TestOutput(testName, f out, f err) + | TraceData.OpenTag(tag, Some d) -> TraceData.OpenTag((mapKnownTags f tag), Some(f d)) + | TraceData.OpenTag(tag, None) -> TraceData.OpenTag((mapKnownTags f tag), None) + | TraceData.CloseTag(tag, time, status) -> TraceData.CloseTag((mapKnownTags f tag), time, status) + | TraceData.BuildState(tag, Some message) -> TraceData.BuildState(tag, Some(f message)) | _ -> t let internal repl (oldStr: string) (repl: string) (s: string) = s.Replace(oldStr, repl) @@ -303,30 +303,30 @@ type ConsoleTraceListener(importantMessagesToStdErr, colorMap, ansiColor) = match msg with | TraceData.ImportantMessage text | TraceData.ErrorMessage text -> write importantMessagesToStdErr color true text - | TraceData.LogMessage (text, newLine) - | TraceData.TraceMessage (text, newLine) -> write false color newLine text - | TraceData.OpenTag (KnownTags.Target _ as tag, description) - | TraceData.OpenTag (KnownTags.FailureTarget _ as tag, description) - | TraceData.OpenTag (KnownTags.FinalTarget _ as tag, description) -> + | TraceData.LogMessage(text, newLine) + | TraceData.TraceMessage(text, newLine) -> write false color newLine text + | TraceData.OpenTag(KnownTags.Target _ as tag, description) + | TraceData.OpenTag(KnownTags.FailureTarget _ as tag, description) + | TraceData.OpenTag(KnownTags.FinalTarget _ as tag, description) -> let color2 = colorMap (TraceData.TraceMessage("", true)) match description with | Some d -> write false color2 true (sprintf "Starting %s '%s': %s" tag.Type tag.Name d) | _ -> write false color2 true (sprintf "Starting %s '%s'" tag.Type tag.Name) - | TraceData.OpenTag (tag, description) -> + | TraceData.OpenTag(tag, description) -> match description with | Some d -> write false color true (sprintf "Starting %s '%s': %s" tag.Type tag.Name d) | _ -> write false color true (sprintf "Starting %s '%s'" tag.Type tag.Name) - | TraceData.CloseTag (tag, time, status) -> + | TraceData.CloseTag(tag, time, status) -> write false color true (sprintf "Finished (%A) '%s' in %O" status tag.Name time) - | TraceData.ImportData (typ, path) -> write false color true (sprintf "Import data '%O': %s" typ path) - | TraceData.BuildState (state, None) -> write false color true (sprintf "Changing BuildState to: %A" state) - | TraceData.BuildState (state, Some message) -> + | TraceData.ImportData(typ, path) -> write false color true (sprintf "Import data '%O': %s" typ path) + | TraceData.BuildState(state, None) -> write false color true (sprintf "Changing BuildState to: %A" state) + | TraceData.BuildState(state, Some message) -> write false color true (sprintf "Changing BuildState to: %A - %s" state message) - | TraceData.TestOutput (test, out, err) -> + | TraceData.TestOutput(test, out, err) -> write false color true (sprintf "Test '%s' output:\n\tOutput: %s\n\tError: %s" test out err) | TraceData.BuildNumber number -> write false color true (sprintf "Build Number: %s" number) - | TraceData.TestStatus (test, status) -> write false color true (sprintf "Test '%s' status: %A" test status) + | TraceData.TestStatus(test, status) -> write false color true (sprintf "Test '%s' status: %A" test status) type TraceSecret = { Value: string; Replacement: string } @@ -350,10 +350,7 @@ module TraceSecrets = if not <| String.IsNullOrEmpty(secret) then getAll () |> List.filter (fun s -> s.Value <> secret) - |> fun l -> - { Value = secret - Replacement = replacement } - :: l + |> fun l -> { Value = secret; Replacement = replacement } :: l |> setTraceSecrets let guardMessage (s: string) = diff --git a/src/app/Fake.Core.Vault/Vault.fs b/src/app/Fake.Core.Vault/Vault.fs index 68557f529dd..3f844b48e8a 100644 --- a/src/app/Fake.Core.Vault/Vault.fs +++ b/src/app/Fake.Core.Vault/Vault.fs @@ -142,10 +142,7 @@ module Vault = /// /// The vault which stores the encrypts values /// - type Vault = - internal - { Key: KeyInfo - Variables: Map } + type Vault = internal { Key: KeyInfo; Variables: Map } /// /// Read a vault from the given encrypted variables @@ -178,8 +175,7 @@ module Vault = File.WriteAllText(keyFile, Convert.ToBase64String(key)) - { KeyFile = keyFile - Iv = Convert.ToBase64String(iv) } + { KeyFile = keyFile; Iv = Convert.ToBase64String(iv) } /// An empty vault without any variables let empty = diff --git a/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs b/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs index 2f5ec61b005..53f291b4b1d 100644 --- a/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs +++ b/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs @@ -1,4 +1,4 @@ -namespace Fake.DotNet +namespace Fake.DotNet open System open System.IO @@ -62,10 +62,10 @@ module internal Helper = /// Represents options for configuring the emission of AssemblyInfo /// type AssemblyInfoFileConfig(generateClass: bool, ?emitResharperSupressions: bool, ?useNamespace: string) -// If set to true then SuppressMessage attributes for the Resharper warnings "RedundantNameQualifier", -// "UnusedMember.Global" and "BuiltInTypeReferenceStyle" will be generated; optional, defaults to false -// The optional namespace into which assembly info will be generated; defaults to "System". - = + // If set to true then SuppressMessage attributes for the Resharper warnings "RedundantNameQualifier", + // "UnusedMember.Global" and "BuiltInTypeReferenceStyle" will be generated; optional, defaults to false + // The optional namespace into which assembly info will be generated; defaults to "System". + = member _.GenerateClass = generateClass member _.UseNamespace = @@ -407,12 +407,13 @@ module AssemblyInfoFile = getDependencies attributes let attributeLines = - [ "// Auto-Generated by FAKE; do not edit"; "// " ] - @ (dependencies |> List.map (sprintf "using %s;")) - @ [ "" ] - @ (attributes + [ yield! [ "// Auto-Generated by FAKE; do not edit"; "// " ] + yield! (dependencies |> List.map (sprintf "using %s;")) + yield! [ "" ] + yield! + (attributes |> Seq.toList - |> List.map (fun (attr: Attribute) -> sprintf "[assembly: %s(%s)]" attr.Name attr.Value)) + |> List.map (fun (attr: Attribute) -> sprintf "[assembly: %s(%s)]" attr.Name attr.Value)) ] let sourceLines = if generateClass then @@ -430,9 +431,10 @@ module AssemblyInfoFile = else [] - (sprintf "namespace %s {" useNamespace) :: resharperSuppressions - @ [ " internal static class AssemblyVersionInformation {" ] - @ consts @ [ " }"; "}" ] + [ yield! (sprintf "namespace %s {" useNamespace) :: resharperSuppressions + yield! [ " internal static class AssemblyVersionInformation {" ] + yield! consts + yield! [ " }"; "}" ] ] else [] @@ -487,12 +489,13 @@ module AssemblyInfoFile = let generateClass, _ = config.GenerateClass, config.UseNamespace let attributeLines = - [ "'//' Auto-Generated by FAKE; do not edit"; "'//' " ] - @ (getDependencies attributes |> List.map (sprintf "Imports %s")) - @ [ "" ] - @ (attributes + [ yield! [ "'//' Auto-Generated by FAKE; do not edit"; "'//' " ] + yield! (getDependencies attributes |> List.map (sprintf "Imports %s")) + yield! [ "" ] + yield! + (attributes |> Seq.toList - |> List.map (fun (attr: Attribute) -> sprintf "" attr.Name attr.Value)) + |> List.map (fun (attr: Attribute) -> sprintf "" attr.Name attr.Value)) ] let sourceLines = if generateClass then @@ -524,16 +527,18 @@ module AssemblyInfoFile = // namespace Namespace1 { namespace Namespace2 { }} //etc let attributeLines = - [ "'//' Auto-Generated by FAKE; do not edit"; "'//' " ] - @ (getDependencies attributes - |> List.map ( - String.collect (fun c -> if c = '.' then "::" else c.ToString()) - >> sprintf "using namespace %s;" - )) - @ [ "" ] - @ (attributes + [ yield! [ "'//' Auto-Generated by FAKE; do not edit"; "'//' " ] + yield! + (getDependencies attributes + |> List.map ( + String.collect (fun c -> if c = '.' then "::" else c.ToString()) + >> sprintf "using namespace %s;" + )) + yield! [ "" ] + yield! + (attributes |> Seq.toList - |> List.map (fun (attr: Attribute) -> sprintf "[assembly:%sAttribute(%s)];" attr.Name attr.Value)) + |> List.map (fun (attr: Attribute) -> sprintf "[assembly:%sAttribute(%s)];" attr.Name attr.Value)) ] attributeLines |> writeToFile outputFileName @@ -627,7 +632,7 @@ module AssemblyInfoFile = | _ -> failwithf "Assembly info file type not supported: %s" assemblyInfoFile let assemblyMap (m: Match) = - let v = m.Groups[ "value" ].Value.Trim([| '"' |]) + let v = m.Groups["value"].Value.Trim([| '"' |]) let n = m.Groups["name"].Value |> removeAtEnd "Attribute" let t = diff --git a/src/app/Fake.DotNet.Cli/DotNet.fs b/src/app/Fake.DotNet.Cli/DotNet.fs index 4224c5764d7..8f19bd79f01 100644 --- a/src/app/Fake.DotNet.Cli/DotNet.fs +++ b/src/app/Fake.DotNet.Cli/DotNet.fs @@ -875,7 +875,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } @@ -945,7 +946,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// @@ -1009,10 +1011,7 @@ module DotNet = try let result = getVersion (fun opt -> - opt.WithCommon(fun c -> - { c with - DotNetCliPath = dotnet - Version = None })) + opt.WithCommon(fun c -> { c with DotNetCliPath = dotnet; Version = None })) result = version with e -> @@ -1034,10 +1033,7 @@ module DotNet = | Some dotnet, passVersion -> Trace.traceVerbose "Suitable dotnet installation found, skipping .NET SDK installer." - (fun opt -> - { opt with - DotNetCliPath = dotnet - Version = passVersion }) + (fun opt -> { opt with DotNetCliPath = dotnet; Version = passVersion }) | _ -> let passVersion = if fromGlobalJson then None else checkVersion @@ -1107,10 +1103,7 @@ module DotNet = let exe = dir @@ (if Environment.isUnix then "dotnet" else "dotnet.exe") Trace.tracefn ".NET Core SDK installed to %s" exe - (fun opt -> - { opt with - DotNetCliPath = exe - Version = passVersion }) + (fun opt -> { opt with DotNetCliPath = exe; Version = passVersion }) /// /// dotnet restore command options @@ -1138,7 +1131,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } @@ -1299,7 +1293,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } @@ -1423,7 +1418,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } @@ -1546,7 +1542,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } @@ -1641,7 +1638,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } @@ -1786,7 +1784,8 @@ module DotNet = /// Sets a value indicating whether the output for the given process is redirected. member x.WithRedirectOutput shouldRedirect = - { x with Common = x.Common.WithRedirectOutput shouldRedirect } + { x with + Common = x.Common.WithRedirectOutput shouldRedirect } /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } @@ -1851,6 +1850,7 @@ module DotNet = PushParams = NuGet.NuGetPushParams.Create() } member this.WithCommon(common: Options) = { this with Common = common } + member this.WithPushParams(options: NuGet.NuGetPushParams) = { this with PushParams = options } /// diff --git a/src/app/Fake.DotNet.FSFormatting/FSFormatting.fs b/src/app/Fake.DotNet.FSFormatting/FSFormatting.fs index 0f45d4e421d..06dd8f25e72 100644 --- a/src/app/Fake.DotNet.FSFormatting/FSFormatting.fs +++ b/src/app/Fake.DotNet.FSFormatting/FSFormatting.fs @@ -1,4 +1,4 @@ -/// Contains tasks which allow to run FSharp.Formatting for generating documentation. +/// Contains tasks which allow to run FSharp.Formatting for generating documentation. [] module Fake.DotNet.FSFormatting @@ -79,17 +79,18 @@ let createDocs p = arguments.ProjectParameters |> Seq.map (fun (k, v) -> [ k; v ]) |> Seq.concat - |> Seq.append ( - [ "literate"; "--processdirectory" ] - @ layoutroots - @ [ "--inputdirectory" - source - "--templatefile" - template - "--outputDirectory" - outputDir ] - @ fsiEval @ [ "--replacements" ] - ) + |> Seq.append + [ yield! [ "literate"; "--processdirectory" ] + yield! layoutroots + yield! + [ "--inputdirectory" + source + "--templatefile" + template + "--outputDirectory" + outputDir ] + yield! fsiEval + yield! [ "--replacements" ] ] |> Seq.map (fun s -> if s.StartsWith "\"" then s else sprintf "\"%s\"" s) |> String.separated " " @@ -145,16 +146,16 @@ let createDocsForDlls (p: MetadataFormatArguments -> MetadataFormatArguments) dl projectParameters |> Seq.map (fun (k, v) -> [ k; v ]) |> Seq.concat - |> Seq.append ( - [ "metadataformat"; "--generate"; "--outdir"; outputDir ] - @ layoutroots - @ libdirs - @ [ "--sourceRepo" + |> Seq.append + [ yield! [ "metadataformat"; "--generate"; "--outdir"; outputDir ] + yield! layoutroots + yield! libdirs + yield! + [ "--sourceRepo" sourceRepo "--sourceFolder" arguments.Source - "--parameters" ] - ) + "--parameters" ] ] |> Seq.map (fun s -> if s.StartsWith "\"" then s else sprintf "\"%s\"" s) |> String.separated " " |> fun prefix -> sprintf "%s --dllfiles %s" prefix (String.separated " " (dllFiles |> Seq.map (sprintf "\"%s\""))) diff --git a/src/app/Fake.DotNet.Fsc/Fsc.fs b/src/app/Fake.DotNet.Fsc/Fsc.fs index cc27525f090..8feb853c6b3 100644 --- a/src/app/Fake.DotNet.Fsc/Fsc.fs +++ b/src/app/Fake.DotNet.Fsc/Fsc.fs @@ -341,14 +341,14 @@ module Fsc = | LinkResource rinfo -> argp "linkresource" <| resourceStr rinfo | Debug on -> stogl "g" on | DebugType dt -> argp "debug" <| string dt - | Optimize (on, opts) -> + | Optimize(on, opts) -> match opts with | [] -> stogl "O" on | _ -> toglls "O" on opts | Tailcalls on -> togl "tailcalls" on | CrossOptimize on -> togl "crossoptimize" on | WarnAsError on -> togl "warnaserror" on - | WarnAsErrors (on, warningCodes) -> toglls "warnaserror" on warningCodes + | WarnAsErrors(on, warningCodes) -> toglls "warnaserror" on warningCodes | Warn lvl -> argp "warn" <| string ( diff --git a/src/app/Fake.DotNet.FxCop/FxCop.fs b/src/app/Fake.DotNet.FxCop/FxCop.fs index 081c4658ba7..542a4e809d6 100644 --- a/src/app/Fake.DotNet.FxCop/FxCop.fs +++ b/src/app/Fake.DotNet.FxCop/FxCop.fs @@ -168,7 +168,8 @@ module FxCop = let internal createArgs fxparams assemblies = let param = if fxparams.ApplyOutXsl && (String.IsNullOrWhiteSpace fxparams.OutputXslFileName) then - { fxparams with OutputXslFileName = fxparams.ToolPath @@ "Xml" @@ "FxCopReport.xsl" } + { fxparams with + OutputXslFileName = fxparams.ToolPath @@ "Xml" @@ "FxCopReport.xsl" } else fxparams diff --git a/src/app/Fake.DotNet.MSBuild/MSBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs index 61c2322474f..1bc2c4ab88c 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -160,8 +160,7 @@ module private MSBuildExe = @"\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin" @"\MSBuild\15.0\Bin" @"\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" ] } - { Version = "14.0" - Paths = [ @"\MSBuild\14.0\Bin" ] } + { Version = "14.0"; Paths = [ @"\MSBuild\14.0\Bin" ] } { Version = "12.0" Paths = [ @"\MSBuild\12.0\Bin"; @"\MSBuild\12.0\Bin\amd64" ] } ] @@ -259,12 +258,12 @@ module private MSBuildExe = false else match Mono.monoVersion with - | Some (_, Some (version)) when version >= monoVersionToUseMSBuildOn -> true + | Some(_, Some(version)) when version >= monoVersionToUseMSBuildOn -> true | _ -> false let preferMSBuildOnMono = match Environment.monoVersion with - | Some (_, Some (version)) when version >= monoVersionToUseMSBuildOn -> true + | Some(_, Some(version)) when version >= monoVersionToUseMSBuildOn -> true | _ -> false let foundExe = @@ -609,7 +608,7 @@ module MSBuild = x.Properties |> Seq.tryFind (fun (p, _) -> p = "RestorePackages") |> (function - | Some (_, v) -> Boolean.Parse v + | Some(_, v) -> Boolean.Parse v | None -> false) ToolsVersion = x.ToolsVersion Verbosity = x.Verbosity diff --git a/src/app/Fake.DotNet.NuGet/NuGet.fs b/src/app/Fake.DotNet.NuGet/NuGet.fs index 7a391eaa177..9f50c37ae1f 100644 --- a/src/app/Fake.DotNet.NuGet/NuGet.fs +++ b/src/app/Fake.DotNet.NuGet/NuGet.fs @@ -24,13 +24,9 @@ module NuGet = type NugetReferences = string list - type NugetFrameworkReferences = - { FrameworkVersion: string - References: NugetReferences } + type NugetFrameworkReferences = { FrameworkVersion: string; References: NugetReferences } - type NugetFrameworkAssemblyReferences = - { FrameworkVersions: string list - AssemblyName: string } + type NugetFrameworkAssemblyReferences = { FrameworkVersions: string list; AssemblyName: string } /// Specifies that the package contains sources and symbols. type NugetSymbolPackage = @@ -738,7 +734,9 @@ module NuGet = |> TraceSecrets.guardMessage |> failwith with _ when parameters.PublishTrials > 0 -> - publish { parameters with PublishTrials = parameters.PublishTrials - 1 } + publish + { parameters with + PublishTrials = parameters.PublishTrials - 1 } /// /// Creates a new NuGet package based on the given .nuspec or project file. @@ -1176,17 +1174,17 @@ module NuGet = /// [omit] let extractFeedPackageFromJson (data: JObject) isLatestVersion = - { Id = data[ "id" ].ToString() - Version = data[ "version" ].ToString() - Description = data[ "description" ].ToString() - Summary = data[ "summary" ].ToString() + { Id = data["id"].ToString() + Version = data["version"].ToString() + Description = data["description"].ToString() + Summary = data["summary"].ToString() IsLatestVersion = isLatestVersion Authors = String.Join(",", data["authors"] :?> JArray) Owners = String.Join(",", data["authors"] :?> JArray) Tags = String.Join(",", data["tags"] :?> JArray) - ProjectUrl = data[ "projectUrl" ].ToString() - LicenseUrl = data[ "licenseUrl" ].ToString() - Title = data[ "title" ].ToString() } + ProjectUrl = data["projectUrl"].ToString() + LicenseUrl = data["licenseUrl"].ToString() + Title = data["title"].ToString() } /// /// Gets a Package information from NuGet feed by package id. @@ -1204,12 +1202,12 @@ module NuGet = let versionExists = packageVersions - |> List.exists (fun listedVersion -> listedVersion[ "version" ].ToString() = version) + |> List.exists (fun listedVersion -> listedVersion["version"].ToString() = version) if not versionExists then failwithf "Requested %s for package %s is not registered on NuGet" version packageName - let isLatest = (data[ "version" ].ToString() = version) + let isLatest = (data["version"].ToString() = version) // set the requested version instead of latest. data["version"] <- JValue version extractFeedPackageFromJson data isLatest diff --git a/src/app/Fake.DotNet.Paket/Paket.fs b/src/app/Fake.DotNet.Paket/Paket.fs index f5684423851..032296b7c24 100644 --- a/src/app/Fake.DotNet.Paket/Paket.fs +++ b/src/app/Fake.DotNet.Paket/Paket.fs @@ -205,7 +205,7 @@ module Paket = let internal createProcess (runType: StartType) = match runType with - | PushFile (parameters, file) -> + | PushFile(parameters, file) -> Arguments.OfArgs [ "push" ] |> Arguments.appendNotEmpty "--url" parameters.PublishUrl |> Arguments.appendNotEmpty "--endpoint" parameters.EndPoint diff --git a/src/app/Fake.DotNet.Paket/PaketTemplate.fs b/src/app/Fake.DotNet.Paket/PaketTemplate.fs index b30a94f4310..8f2fe03e449 100644 --- a/src/app/Fake.DotNet.Paket/PaketTemplate.fs +++ b/src/app/Fake.DotNet.Paket/PaketTemplate.fs @@ -241,7 +241,7 @@ module internal Rendering = let inline renderPaketFileInfo fileInfo = match fileInfo with - | Include (source, target) -> sprintf "%s ==> %s" source target + | Include(source, target) -> sprintf "%s ==> %s" source target | Exclude file -> sprintf "!%s" file let inline appendPaketFileInfos (fileInfos: PaketFileInfo seq) (sb: StringBuilder) = diff --git a/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs b/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs index 4b40c44956f..5efd31e0293 100644 --- a/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs +++ b/src/app/Fake.DotNet.Testing.Coverlet/Coverlet.fs @@ -148,4 +148,5 @@ module Coverlet = /// The coverlet parameters /// DotNet test cli command options let withDotNetTestOptions (param: CoverletParams -> CoverletParams) (options: DotNet.TestOptions) = - { options with MSBuildParams = withMSBuildArguments param options.MSBuildParams } + { options with + MSBuildParams = withMSBuildArguments param options.MSBuildParams } diff --git a/src/app/Fake.DotNet.Testing.NUnit/Parallel.fs b/src/app/Fake.DotNet.Testing.NUnit/Parallel.fs index 95ce692cc9a..5e25c64dc20 100644 --- a/src/app/Fake.DotNet.Testing.NUnit/Parallel.fs +++ b/src/app/Fake.DotNet.Testing.NUnit/Parallel.fs @@ -27,9 +27,7 @@ module Parallel = { WorseReturnCode: int Messages: string list } - static member Empty = - { WorseReturnCode = Int32.MaxValue - Messages = [] } + static member Empty = { WorseReturnCode = Int32.MaxValue; Messages = [] } /// /// Runs NUnit in parallel on a group of assemblies. diff --git a/src/app/Fake.DotNet.Testing.OpenCover/OpenCover.fs b/src/app/Fake.DotNet.Testing.OpenCover/OpenCover.fs index 640c76e8aac..2e59e197823 100644 --- a/src/app/Fake.DotNet.Testing.OpenCover/OpenCover.fs +++ b/src/app/Fake.DotNet.Testing.OpenCover/OpenCover.fs @@ -91,7 +91,9 @@ module OpenCover = String.Empty else Environment.environVar "LOCALAPPDATA" - @@ "Apps" @@ "OpenCover" @@ "OpenCover.Console.exe" + @@ "Apps" + @@ "OpenCover" + @@ "OpenCover.Console.exe" TestRunnerExePath = if Environment.isMono then String.Empty diff --git a/src/app/Fake.DotNet.Xamarin/Xamarin.fs b/src/app/Fake.DotNet.Xamarin/Xamarin.fs index 95309a2c0d3..07e13265873 100644 --- a/src/app/Fake.DotNet.Xamarin/Xamarin.fs +++ b/src/app/Fake.DotNet.Xamarin/Xamarin.fs @@ -460,7 +460,8 @@ module Xamarin = let createPackageAbiSpecificApk param (targets: AndroidAbiTarget list) transformVersion = let manifestPath = (param.ProjectPath |> Path.GetDirectoryName) - @@ @"Properties" @@ "AndroidManifest.xml" + @@ @"Properties" + @@ "AndroidManifest.xml" seq { for t in targets do diff --git a/src/app/Fake.IO.FileSystem/ChangeWatcher.fs b/src/app/Fake.IO.FileSystem/ChangeWatcher.fs index e39d80102d7..3e7dd1b4c5a 100644 --- a/src/app/Fake.IO.FileSystem/ChangeWatcher.fs +++ b/src/app/Fake.IO.FileSystem/ChangeWatcher.fs @@ -16,10 +16,7 @@ type FileStatus = /// /// Capture file change operation, see FileStatus /// -type FileChange = - { FullPath: string - Name: string - Status: FileStatus } +type FileChange = { FullPath: string; Name: string; Status: FileStatus } /// /// This module contains helpers to react to file system events. @@ -44,10 +41,7 @@ module ChangeWatcher = type Options = { IncludeSubdirectories: bool } let private handleWatcherEvents (status: FileStatus) (onChange: FileChange -> unit) (e: FileSystemEventArgs) = - onChange - { FullPath = e.FullPath - Name = e.Name - Status = status } + onChange { FullPath = e.FullPath; Name = e.Name; Status = status } /// /// Watches for changes in the matching files. @@ -125,10 +119,7 @@ module ChangeWatcher = Name = e.OldName Status = Deleted } - acumChanges - { FullPath = e.FullPath - Name = e.Name - Status = Created }) + acumChanges { FullPath = e.FullPath; Name = e.Name; Status = Created }) watcher) diff --git a/src/app/Fake.IO.FileSystem/GlobbingFileSystem.fs b/src/app/Fake.IO.FileSystem/GlobbingFileSystem.fs index 601109df82b..69c52f2cfd5 100644 --- a/src/app/Fake.IO.FileSystem/GlobbingFileSystem.fs +++ b/src/app/Fake.IO.FileSystem/GlobbingFileSystem.fs @@ -117,7 +117,9 @@ module GlobbingPatternExtensions = /// Sets a directory as BaseDirectory. member this.SetBaseDirectory(dir: string) = - { this.Pattern with BaseDirectory = dir.TrimEnd(Path.DirectorySeparatorChar) } :> IGlobbingPattern + { this.Pattern with + BaseDirectory = dir.TrimEnd(Path.DirectorySeparatorChar) } + :> IGlobbingPattern /// Checks if a particular file is matched member this.IsMatch(path: string) = @@ -156,10 +158,7 @@ module GlobbingPattern = /// Start an empty globbing pattern from the specified directory let createFrom (dir: string) = - { BaseDirectory = dir - Includes = [] - Excludes = [] } - :> IGlobbingPattern + { BaseDirectory = dir; Includes = []; Excludes = [] } :> IGlobbingPattern /// Sets a directory as baseDirectory for fileIncludes. let setBaseDir (dir: string) (fileIncludes: IGlobbingPattern) = fileIncludes.SetBaseDirectory dir diff --git a/src/app/Fake.IO.FileSystem/Shell.fs b/src/app/Fake.IO.FileSystem/Shell.fs index 0800feae4d8..f189f017b44 100644 --- a/src/app/Fake.IO.FileSystem/Shell.fs +++ b/src/app/Fake.IO.FileSystem/Shell.fs @@ -435,13 +435,13 @@ module Shell = | Overwrite -> DirectoryInfo.copyRecursiveTo true dirInfo outputDirInfo | NoOverwrite -> DirectoryInfo.copyRecursiveTo false dirInfo outputDirInfo | Skip -> copyRecursiveWithFilter <| fun d f -> d.FullName @@ f.Name |> File.Exists |> not - | IncludePattern (pattern) -> + | IncludePattern(pattern) -> copyRecursiveWithFilter <| fun d f -> d.FullName @@ f.Name |> (Glob.isMatch pattern) - | ExcludePattern (pattern) -> + | ExcludePattern(pattern) -> copyRecursiveWithFilter <| fun d f -> d.FullName @@ f.Name |> (Glob.isMatch pattern) |> not - | Filter (f) -> copyRecursiveWithFilter f + | Filter(f) -> copyRecursiveWithFilter f /// /// Moves a single file to the target and overwrites the existing file. @@ -470,7 +470,7 @@ module Shell = let fi = FileSystemInfo.ofPath fileName match fi with - | FileSystemInfo.Directory (d, _) -> + | FileSystemInfo.Directory(d, _) -> let targetName = target @@ fi.Name d.MoveTo(targetName) | FileSystemInfo.File _ -> failwithf "moveDir only works on directories but '%s' was a file." fileName diff --git a/src/app/Fake.Installer.Wix/Wix.fs b/src/app/Fake.Installer.Wix/Wix.fs index 16cceb8aefb..2447b430b00 100644 --- a/src/app/Fake.Installer.Wix/Wix.fs +++ b/src/app/Fake.Installer.Wix/Wix.fs @@ -850,11 +850,7 @@ module Wix = parameters /// Defaults for directories - let internal DirDefaults = - { Id = "" - Name = "" - Files = [] - Components = [] } + let internal DirDefaults = { Id = ""; Name = ""; Files = []; Components = [] } /// Use this for generating directories let internal generateDirectory (setParams: Dir -> Dir) = @@ -1639,10 +1635,7 @@ module Wix = + "\"/>" /// Default value for WiX Variable - let internal VariableDefaults = - { Id = "" - Overridable = YesOrNo.No - Value = "" } + let internal VariableDefaults = { Id = ""; Overridable = YesOrNo.No; Value = "" } /// Parameters for WiX Script properties, use ToString for creating the string xml nodes type Script = diff --git a/src/app/Fake.Net.FTP/FTP.fs b/src/app/Fake.Net.FTP/FTP.fs index dd46de9877a..3b9a19f49c4 100644 --- a/src/app/Fake.Net.FTP/FTP.fs +++ b/src/app/Fake.Net.FTP/FTP.fs @@ -46,8 +46,7 @@ module FTP = ftpRequest.Credentials <- NetworkCredential(user, password) ftpRequest.Method <- ftpMethod - { Server = serverNameIp - Request = ftpRequest } + { Server = serverNameIp; Request = ftpRequest } /// Writes given byte array into the given stream let rec private writeChunkToReqStream (chunk: byte[]) (requestStream: Stream) (br: BinaryReader) = diff --git a/src/app/Fake.Runtime/CompileRunner.fs b/src/app/Fake.Runtime/CompileRunner.fs index 7232dacd5a8..f0dadc2d6e1 100644 --- a/src/app/Fake.Runtime/CompileRunner.fs +++ b/src/app/Fake.Runtime/CompileRunner.fs @@ -166,7 +166,9 @@ let compile (context: FakeContext) outDll = FullPaths = true ScriptArgs = "--simpleresolution" - :: targetProfile :: "--nowin32manifest" :: fcsDependencyManagerOptions + :: targetProfile + :: "--nowin32manifest" + :: fcsDependencyManagerOptions @ "-o" :: outDll :: context.Config.ScriptFilePath :: co.FsiOptions.ScriptArgs } // Replace fsharp.core with current version, see https://github.com/fsharp/FAKE/issues/2001 let fixReferences (s: string list) = @@ -194,7 +196,9 @@ let compile (context: FakeContext) outDll = else resultList - let options = { options with References = fixReferences options.References } + let options = + { options with + References = fixReferences options.References } let args = options.AsArgs |> Seq.toList |> List.filter (fun arg -> arg <> "--") diff --git a/src/app/Fake.Runtime/CoreCache.fs b/src/app/Fake.Runtime/CoreCache.fs index a7aba563a09..dc8a3836dab 100644 --- a/src/app/Fake.Runtime/CoreCache.fs +++ b/src/app/Fake.Runtime/CoreCache.fs @@ -101,9 +101,7 @@ module internal Cache = let warnings = warningsFileName context let warningText = File.ReadAllText warnings - Some - { CompiledAssembly = cachedDll - Warnings = warningText } + Some { CompiledAssembly = cachedDll; Warnings = warningText } else None @@ -214,7 +212,9 @@ module internal Cache = { context with Config = { context.Config with - CompileOptions = { context.Config.CompileOptions with FsiOptions = newAdditionalArgs } + CompileOptions = + { context.Config.CompileOptions with + FsiOptions = newAdditionalArgs } RuntimeOptions = { context.Config.RuntimeOptions with _RuntimeDependencies = @@ -286,7 +286,7 @@ let findInAssemblyList (name: AssemblyName) (runtimeDependencies: AssemblyInfo l |> Seq.map (fun r -> AssemblyName(r.FullName), r) |> Seq.tryFind (fun (n, _) -> n.Name = name.Name && (emptyToken || n.GetPublicKeyToken() = token)) with - | Some (otherName, info) -> + | Some(otherName, info) -> // Then the version matches or is null and the public token is null we still accept this as perfect match Some((emptyToken && (emptyVersion || otherName.Version = name.Version)), info) | _ -> None @@ -368,11 +368,11 @@ let findAndLoadInRuntimeDeps tracefn "Could not find assembly in the default load-context: %s" strName match runtimeDependencies |> findInAssemblyList name with - | Some (perfectMatch, a) -> perfectMatch, loadAssembly loadContext logLevel a + | Some(perfectMatch, a) -> perfectMatch, loadAssembly loadContext logLevel a | None -> false, None match result with - | Some (location, a) -> + | Some(location, a) -> if logLevel.PrintVerbose then if isPerfectMatch then tracefn "Redirect assembly load to known assembly: %s (%A)" strName location @@ -394,7 +394,11 @@ let findAndLoadInRuntimeDepsCached = let assemblyCache = System.Collections.Concurrent.ConcurrentDictionary<_, Assembly>() - fun (loadContext: AssemblyLoadContext) (name: AssemblyName) (logLevel: Trace.VerboseLevel) (runtimeDependencies: AssemblyInfo list) -> + fun + (loadContext: AssemblyLoadContext) + (name: AssemblyName) + (logLevel: Trace.VerboseLevel) + (runtimeDependencies: AssemblyInfo list) -> let mutable wasCalled = false let result = @@ -474,7 +478,11 @@ let findUnmanagedInRuntimeDeps let resolveUnmanagedDependencyCached = let libCache = System.Collections.Concurrent.ConcurrentDictionary<_, string>() - fun (loadFromPath: string -> nativeint) (unmanagedDllName: string) (logLevel: Trace.VerboseLevel) (nativeLibraries: NativeLibrary list) -> + fun + (loadFromPath: string -> nativeint) + (unmanagedDllName: string) + (logLevel: Trace.VerboseLevel) + (nativeLibraries: NativeLibrary list) -> let mutable wasCalled = false let path = @@ -514,11 +522,7 @@ This can happen for various reasons: #if NETSTANDARD1_6 // See https://github.com/dotnet/coreclr/issues/6411 type FakeLoadContext - ( - printDetails: Trace.VerboseLevel, - dependencies: AssemblyInfo list, - nativeLibraries: NativeLibrary list - ) = + (printDetails: Trace.VerboseLevel, dependencies: AssemblyInfo list, nativeLibraries: NativeLibrary list) = // Mark as Collectible once supported: https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability-howto?view=netcore-3.0 inherit AssemblyLoadContext() let allReferences = dependencies @@ -584,9 +588,7 @@ let prepareContext (config: FakeConfig) (cache: ICachingProvider) = |> Seq.map (Path.readPathFromCache config.ScriptFilePath) |> Seq.map (fun line -> if File.Exists line then - Some - { HashContent = File.ReadAllText line - Location = line } + Some { HashContent = File.ReadAllText line; Location = line } else None) |> Seq.toList diff --git a/src/app/Fake.Runtime/FSharpParser.fs b/src/app/Fake.Runtime/FSharpParser.fs index 197965534b1..b2a8c29a844 100644 --- a/src/app/Fake.Runtime/FSharpParser.fs +++ b/src/app/Fake.Runtime/FSharpParser.fs @@ -76,9 +76,7 @@ type internal StringLike = | StringItem of string | StringKeyword of StringKeyword -type internal PreprocessorDirective = - { Token: Token - Strings: StringLike list } +type internal PreprocessorDirective = { Token: Token; Strings: StringLike list } let internal handleRawString (s: string) = if s.StartsWith("\"") then @@ -143,7 +141,7 @@ let internal findProcessorDirectives { Tokens = tokens } = match items, collectDirective, token.TokenInfo with | h :: rest, true, Some _ -> (token :: h) :: rest, true | _, true, None -> items, false - | _, false, Some (tok) when tok.TokenName = "HASH" -> [ token ] :: items, true + | _, false, Some(tok) when tok.TokenName = "HASH" -> [ token ] :: items, true | _, false, _ -> items, false | _ -> failwithf "Unknown state %A" (items, collectDirective, token)) ([], false) @@ -177,7 +175,7 @@ let internal findInterestingItems { Tokens = tokens } = None, Reference(Some "") else None, Reference None - | Reference (Some s) -> // read string + | Reference(Some s) -> // read string if tok.TokenInfo.IsNone || (tok.TokenInfo.IsSome && tok.TokenInfo.Value.TokenName = "STRING_TEXT") diff --git a/src/app/Fake.Runtime/FakeHeader.fs b/src/app/Fake.Runtime/FakeHeader.fs index d5476813cc0..f8655b05996 100644 --- a/src/app/Fake.Runtime/FakeHeader.fs +++ b/src/app/Fake.Runtime/FakeHeader.fs @@ -181,8 +181,7 @@ let tryReadPaketDependenciesFromScript else "framework: netstandard2.0,net6.0" + "\n" + p - { Header = PaketInline - Section = fixDefaults paketCode } + { Header = PaketInline; Section = fixDefaults paketCode } |> writeFixedPaketDependencies cacheDir |> Some else diff --git a/src/app/Fake.Runtime/FakeRuntime.fs b/src/app/Fake.Runtime/FakeRuntime.fs index b6c5705f343..8332bdf5e43 100644 --- a/src/app/Fake.Runtime/FakeRuntime.fs +++ b/src/app/Fake.Runtime/FakeRuntime.fs @@ -14,9 +14,7 @@ open Fake.Runtime.SdkAssemblyResolver open Paket open System -type AssemblyData = - { IsReferenceAssembly: bool - Info: Runners.AssemblyInfo } +type AssemblyData = { IsReferenceAssembly: bool; Info: Runners.AssemblyInfo } [] type DependencyFile = @@ -497,14 +495,16 @@ let paketCachingProvider { context with Config = { context.Config with - CompileOptions = { context.Config.CompileOptions with FsiOptions = newAdditionalArgs } + CompileOptions = + { context.Config.CompileOptions with + FsiOptions = newAdditionalArgs } RuntimeOptions = { context.Config.RuntimeOptions with _RuntimeDependencies = runtimeAssemblies @ context.Config.RuntimeOptions.RuntimeDependencies _NativeLibraries = nativeLibraries @ context.Config.RuntimeOptions.NativeLibraries } - } }, + } }, let assemblyPath, warningsFile = context.CachedAssemblyFilePath + ".dll", context.CachedAssemblyFilePath + ".warnings" @@ -526,7 +526,7 @@ let paketCachingProvider let internal restoreDependencies config cacheDir section = match section with - | FakeHeader.PaketDependencies (_, paketDependencies, paketDependenciesFile, group) -> + | FakeHeader.PaketDependencies(_, paketDependencies, paketDependenciesFile, group) -> paketCachingProvider config cacheDir paketDependencies paketDependenciesFile group let internal tryFindGroupFromDepsFile scriptDir = @@ -622,7 +622,7 @@ let tryPrepareFakeScript (config: FakeConfig) : TryPrepareInfo = let writeToCache (section: FakeHeader.FakeSection option) = let content = match section with - | Some (FakeHeader.PaketDependencies (headerType, p, _, group)) -> + | Some(FakeHeader.PaketDependencies(headerType, p, _, group)) -> let s = match headerType with | FakeHeader.PaketInline -> "paket-inline" @@ -697,8 +697,8 @@ let tryPrepareFakeScript (config: FakeConfig) : TryPrepareInfo = _Section = section _DependencyType = match section with - | FakeHeader.PaketDependencies (FakeHeader.PaketInline, _, _, _) -> PreparedDependencyType.PaketInline - | FakeHeader.PaketDependencies (FakeHeader.PaketDependenciesRef, _, _, _) -> + | FakeHeader.PaketDependencies(FakeHeader.PaketInline, _, _, _) -> PreparedDependencyType.PaketInline + | FakeHeader.PaketDependencies(FakeHeader.PaketDependenciesRef, _, _, _) -> PreparedDependencyType.PaketDependenciesRef } |> Prepared | None -> NoHeader(cacheDir, (fun () -> actions |> List.rev |> List.iter (fun f -> f ()))) @@ -707,7 +707,7 @@ let tryPrepareFakeScript (config: FakeConfig) : TryPrepareInfo = let prepareFakeScript (config: FakeConfig) : PrepareInfo = match tryPrepareFakeScript config with | Prepared s -> s - | NoHeader (cacheDir, saveCache) -> + | NoHeader(cacheDir, saveCache) -> saveCache () let defaultPaketCode = @@ -766,7 +766,7 @@ let createConfig #else Defines = "DOTNETCORE" :: "FAKE" :: fsiOptionsObj.Defines #endif - } + } // Make sure to not access forward-writer, see https://github.com/fsharp/FAKE/issues/2503 let redirectWriter = @@ -774,6 +774,7 @@ let createConfig |> Option.map (fun (onOutMsg, onErrMsg) -> let out = Yaaf.FSharp.Scripting.ScriptHost.CreateForwardWriter onOutMsg let err = Yaaf.FSharp.Scripting.ScriptHost.CreateForwardWriter onErrMsg + { Out = out; Err = err }) let tokenized = @@ -785,9 +786,7 @@ let createConfig Runners.FakeConfig.ScriptFilePath = Path.GetFullPath scriptPath Runners.FakeConfig.ScriptTokens = tokenized Runners.FakeConfig.CompileOptions = { FsiOptions = newFsiOptions } - Runners.FakeConfig.RuntimeOptions = - { _RuntimeDependencies = [] - _NativeLibraries = [] } + Runners.FakeConfig.RuntimeOptions = { _RuntimeDependencies = []; _NativeLibraries = [] } Runners.FakeConfig.UseSimpleRestore = false Runners.FakeConfig.UseCache = useCache Runners.FakeConfig.RestoreOnlyGroup = restoreOnlyGroup diff --git a/src/app/Fake.Runtime/FakeRuntimeHints.fs b/src/app/Fake.Runtime/FakeRuntimeHints.fs index 51948cd6efd..18bf664e624 100644 --- a/src/app/Fake.Runtime/FakeRuntimeHints.fs +++ b/src/app/Fake.Runtime/FakeRuntimeHints.fs @@ -103,7 +103,7 @@ let retrieveHints let paketCoreVersionString = paketVersion match prepareInfo._Section with - | FakeHeader.PaketDependencies (_, d, _, _) -> + | FakeHeader.PaketDependencies(_, d, _, _) -> match getBootstrapperArgs d.DependenciesFile with | None -> { Important = false @@ -157,6 +157,7 @@ let retrieveHints /// [omit] let getLinkerTime (assembly: Assembly) = let buildVersionMetadataPrefix = "+build" + let attribute = assembly.GetCustomAttribute() match attribute.InformationalVersion <> null with diff --git a/src/app/Fake.Runtime/HashGeneration.fs b/src/app/Fake.Runtime/HashGeneration.fs index c441b4aebce..0ee2b859898 100644 --- a/src/app/Fake.Runtime/HashGeneration.fs +++ b/src/app/Fake.Runtime/HashGeneration.fs @@ -8,9 +8,7 @@ open System.Xml.Linq open Yaaf.FSharp.Scripting open Fake.Runtime -type Script = - { HashContent: string - Location: string } +type Script = { HashContent: string; Location: string } let getAllScriptContents (pathsAndContents: seq