Switch release publish to Native AOT#53
Merged
Merged
Conversation
Release builds now publish as a single native binary (~12MB on osx-arm64) instead of a 87MB self-contained single-file. Startup no longer pays JIT cost — relevant for a TUI editor launched frequently. - `PublishAot=true` on TuiCode (only affects `dotnet publish`; `dotnet build`/`run` still JIT). - `IsAotCompatible=true` on all src projects so trim/AOT analyzers run on every Debug build — regressions caught at compile time, not at publish time. - Fix the one warning that surfaced: `JsonArray.Add(JsonNode?)` in `DefaultSettingsService.SaveKeybindings` instead of the generic `Add<T>(T)`, which is flagged RequiresUnreferencedCode + RequiresDynamicCode. - Drop the unused `Microsoft.Extensions.Hosting` package reference (only `ServiceCollection` from DI is used). Terminal.Gui v2.1.0 and System.IO.Abstractions produce no AOT warnings. All 93 tests still pass; AOT publish is clean (0 warnings). Tests still run under JIT — AOT-compatible test tooling will be investigated separately.
`dotnet test` runs under JIT, so trim-stripped paths and missing metadata only blow up against the published native binary — classes of failure neither the JIT test suite nor the publish-time analyzers catch. - `--smoke` in Program.cs: hooks the first Iteration to call RequestStop, so the app boots through Application.Init, paints one frame, exits 0. - CI workflow step publishes AOT for linux-x64 and runs the binary under `script` (pty allocation — TG needs a terminal) with a 20s timeout. Validated locally: `script -q /dev/null TuiCode --smoke` returns exit 0 with a full first paint in the log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #42.
Summary
dotnet build/dotnet runare unaffected and still JIT.IsAotCompatible=trueon allsrc/projects so trim/AOT analyzers run on every Debug build. Any regression breaks the build, not justpublish.DefaultSettingsService.SaveKeybindingswas hittingJsonArray.Add<T>(T)(RequiresUnreferencedCode + RequiresDynamicCode). Cast toJsonNodeto pick the non-generic overload.Microsoft.Extensions.Hostingpackage reference. OnlyServiceCollectionfrom DI is used.The risks the issue flagged didn't materialize: Terminal.Gui v2.1.0 and System.IO.Abstractions produce no AOT warnings.
Scope explicitly not in this PR