Skip to content

Marten#4349: AOT publishing guide#4469

Merged
jeremydmiller merged 1 commit into
masterfrom
feat/4349-aot-publishing-guide
May 18, 2026
Merged

Marten#4349: AOT publishing guide#4469
jeremydmiller merged 1 commit into
masterfrom
feat/4349-aot-publishing-guide

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Summary

Ticks the "AOT publishing guide specific to Marten" checkbox on #4349 (Marten 9.0 master plan). New page at docs/configuration/aot-publishing.md (259 lines, within the chip's 200-350 target).

Models after JasperFx's docs/codegen/aot.md (219 lines), adapted to Marten's surface. Main adaptation: the one-phase model — Marten 9 retired runtime code generation entirely in PR #4461, so there's no dotnet run -- codegen write step the JasperFx guide builds around. The Marten guide calls out the difference explicitly with a side-by-side mermaid diagram.

Sections

  1. What AOT publishing buys you + when it's the right choice (and when it isn't)
  2. Prerequisites — .NET 9/10, Marten 9.0+, STJ serializer, optional Marten.SourceGenerator for compiled queries
  3. How Marten 9 differs from the broader Critter Stack — the one-phase model, what to delete if you have a pre-9 Internal/Generated/ folder, why services.AddRuntimeCompilation() doesn't exist anymore
  4. Project setup walkthrough — concrete csproj, AddMarten with STJ, [JasperFxAssembly] marker, publish command
  5. What works / annotated / doesn't work — honest about the ~15 cascading IL2026 / IL3050 warnings from Marten.Internal.ClosedShape.* construction sites that PR Marten#4349: Add Marten.AotSmoke + extension package IsAotCompatible audit #4468's audit surfaced; AOT-publishing apps will see these until the per-document-type source-generator extension lands (tracked on [Master] Marten 9.0 #4349)
  6. The Newtonsoft.Json escape hatch — concrete migration from UseNewtonsoftForSerialization to UseSystemTextJsonForSerialization plus the gotchas (property casing, polymorphic types, DateTime formatting)
  7. Verifying your app is AOT-clean — publish output scan + table mapping warning sources to fix paths + reference to src/Marten.AotSmoke as the canonical clean consumer
  8. Troubleshooting — five common failure modes (missing [GeneratedEvolver], IL3050 on custom projection base, LINQ in AOT, Reflection.Emit secondary-store boot, slow publish)
  9. Performance — cites the Marten.SourceGenerator README's compiled-query benchmark (~25× cold, ~31% steady-state); defers end-to-end AOT cold-start benchmarks to CritterStackScalability
  10. References — JasperFx guide, Marten.SourceGenerator README, migration-guide anchor, MSFT trim-warning catalog, MSFT Native AOT docs

Sidebar

Added under "Configuration" between "Optimized Development Workflow" and "Multi-Tenancy with Database per Tenant" (docs/.vitepress/config.mts:144).

Test plan

References: #4349 (master plan — not "Closes", this just ticks one box).

🤖 Generated with Claude Code

New page at docs/configuration/aot-publishing.md walks through publishing
a Marten-backed .NET app with PublishAot=true. Models after JasperFx's
docs/codegen/aot.md (219 lines), adapted to the Marten 9 surface — main
adaptation is the one-phase model (Marten 9 retired runtime code
generation in #4461, so there's no `dotnet run -- codegen write` step
the JasperFx guide builds around).

Sections:

- What AOT publishing buys you + when it's the right choice
- Prerequisites (.NET 9/10, Marten 9.0+, STJ serializer, optional
  Marten.SourceGenerator)
- How Marten 9 differs from the broader Critter Stack two-phase model
- Project setup walkthrough (csproj, AddMarten with STJ,
  [JasperFxAssembly] marker, publish command)
- What works / annotated / doesn't work — including the ~15 cascading
  IL warnings from Marten.Internal.ClosedShape.* construction sites
  that PR #4468's audit surfaced
- The Newtonsoft.Json escape hatch — concrete migration from
  UseNewtonsoftForSerialization to UseSystemTextJsonForSerialization
- Verifying your app is AOT-clean (publish output scan + reference to
  Marten.AotSmoke)
- Troubleshooting common failure modes (missing GeneratedEvolver,
  IL3050 on custom projection base, LINQ in AOT, Reflection.Emit
  secondary-store boot failure, publish performance)
- Performance — cites the Marten.SourceGenerator README's compiled-
  query benchmark, defers end-to-end AOT cold-start benchmarks to
  CritterStackScalability
- Cross-references — JasperFx guide, Marten.SourceGenerator README,
  migration guide anchor

Sidebar entry added under "Configuration" between "Optimized
Development Workflow" and "Multi-Tenancy with Database per Tenant".

markdownlint + cspell clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit d5ea424 into master May 18, 2026
1 check passed
@jeremydmiller jeremydmiller deleted the feat/4349-aot-publishing-guide branch May 18, 2026 14:49
@jeremydmiller jeremydmiller mentioned this pull request May 18, 2026
38 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant