Skip to content

Fix generate.ps1 error propagation#3569

Merged
mattleibow merged 1 commit intomainfrom
dev/fix-generate-exit-code
Mar 23, 2026
Merged

Fix generate.ps1 error propagation#3569
mattleibow merged 1 commit intomainfrom
dev/fix-generate-exit-code

Conversation

@mattleibow
Copy link
Contributor

Problem

utils/generate.ps1 uses Invoke-Expression + $? to run the generator and check for errors. This silently swallows non-zero exit codes — if the generator crashes (e.g., CppAst parse failure on bad struct definitions), the script continues and exits 0.

Fix

  • Replace Invoke-Expression with splatted args array ($runArgs) and direct invocation via & dotnet @runArgs
  • Continue through all projects to report ALL failures, then exit 1 at the end
  • Single $runArgs array used for both display (Write-Host) and execution (no duplication)

Testing

Verified on macOS:

  • ✅ Good code (skiasharp base): exits 0, generation succeeds
  • ✅ Bad code (PR 171 with broken structs): exits 1, reports ERROR: Generation failed for libSkiaSharp.json with exit code 1

- Replace Invoke-Expression with splatted args array ($runArgs) for proper
  exit code propagation — Invoke-Expression silently swallows non-zero exits
- Continue through all projects to report ALL failures, then exit 1
- Use $LASTEXITCODE instead of $? for reliable native command error detection

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattleibow mattleibow merged commit 3b95f38 into main Mar 23, 2026
1 of 2 checks passed
@mattleibow mattleibow deleted the dev/fix-generate-exit-code branch March 23, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant