native-aot
Installation
SKILL.md
Native AOT, Trimming & Single-File (.NET 10)
Core Principles
- Decide early — AOT constrains library choice (no runtime reflection or code generation). Adding it to a mature reflection-heavy app is a rewrite. Adding it on day one costs almost nothing.
- A trim/AOT warning is a future runtime crash — IL2xxx (trimming) and IL3xxx (AOT/single-file) warnings mark code that may throw
MissingMethodExceptionor silently misbehave in the published binary. Treat them as errors and keep the count at zero. - Source generators replace reflection — JSON, regex, logging, configuration binding, options validation, and MVVM all have generators. They keep the AOT path fast and analyzable.
- Test the published artifact, not
dotnet run—dotnet runuses the JIT and full metadata, so it hides every trimming bug. Smoke-test the binary thatdotnet publishproduces, in CI. - AOT is a trade, not a free upgrade — You get fast startup, small memory, and no runtime install. You lose dynamic loading,
Reflection.Emit, and some steady-state throughput from Dynamic PGO. Pick it where those trade-offs pay.