From ee8ce344e4c4be3dcb05a0fed796059ba09598d6 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 1 Jun 2026 11:00:01 +0200 Subject: [PATCH] Speed up dotnet format lint hook from ~85s to ~13s Switch the lint target to dotnet format whitespace --no-restore, which enforces all .editorconfig spacing/indentation rules without the Roslyn semantic analysis passes (style + analyzers) that add ~60s. CI now calls dotnet format --verify-no-changes --no-restore directly so style and analyzer coverage is preserved there. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- build/Targets.fs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build/Targets.fs b/build/Targets.fs index 5881f47dfa..6963474dc5 100644 --- a/build/Targets.fs +++ b/build/Targets.fs @@ -44,11 +44,15 @@ let private watch _ = exec { run "dotnet" "watch" "--project" "src/tooling/docs- let private lint (lintArgs: ParseResults) = let includeFiles = lintArgs.TryGetResult LintArgs.Include |> Option.defaultValue [] - let includeArgs = - if includeFiles.IsEmpty then [] - else ["--include"] @ includeFiles + // When files are provided (pre-push hook): whitespace only — style/analyzers require full Roslyn + // semantic analysis (~60s extra) and are not accidentally introduced during normal coding. + // When no files (CI): full check, but skip restore since packages are already available. + let formatArgs = + match includeFiles with + | [] -> ["format"; "--verify-no-changes"; "--no-restore"] + | files -> ["format"; "whitespace"; "--verify-no-changes"; "--no-restore"; "--include"] @ files match exec { - exit_code_of "dotnet" (["format"; "--verify-no-changes"] @ includeArgs) + exit_code_of "dotnet" formatArgs } with | 0 -> printfn "There are no dotnet formatting violations, continuing the build." | _ -> failwithf "There are dotnet formatting violations. Call `dotnet format` to fix or specify -c to ./build.sh to skip this check"