docs: LoadAsync / strong-typed id codegen sample (GH-2508)#2544
Merged
jeremydmiller merged 1 commit intomainfrom Apr 20, 2026
Merged
docs: LoadAsync / strong-typed id codegen sample (GH-2508)#2544jeremydmiller merged 1 commit intomainfrom
jeremydmiller merged 1 commit intomainfrom
Conversation
Adds a "Custom Variable Sources" section to docs/guide/codegen.md covering the pattern from the CritterStackSamples/Reports sample and the April 20, 2026 blog post. Walks through: 1. The motivating problem — handlers forced to be async and pick up an IDocumentSession dependency just to pull a sequence-generated id before creating an aggregate. 2. Defining the strong-typed id (ReportId) and an IDocumentSession extension that wraps Marten 8.31's NextSequenceValue helper. 3. Implementing IVariableSource (Matches + Create) using a MethodCall frame to teach Wolverine's codegen how to materialize the id. 4. Registering the source on WolverineOptions.CodeGeneration.Sources. 5. How the approach relates to the A-Frame LoadAsync pattern — both can coexist on the same handler; IVariableSource is the better fit when the value is newly created rather than loaded. 6. How to preview the generated code and confirm the source fired. Links out to the full runnable sample at https://github.com/JasperFx/CritterStackSamples/tree/main/Reports. Doc-only change; no code or tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 21, 2026
Closed
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.
Summary
Documentation-only. Adds a "Custom Variable Sources" section to
docs/guide/codegen.mdadapted from the CritterStackSamples/Reports sample and Jeremy's April 20, 2026 blog post.Covers the pattern of using an
IVariableSourceto materialize strong-typed identifiers (or any custom type) as a handler parameter — pulling the async factory call out of the handler body and into the generated wrapper.Structure of the new section
IDocumentSessionin as infrastructure noise.GetNextReportIdextension (uses Marten 8.31'sNextSequenceValue).IVariableSource—Matches+Create, with aMethodCallframe so the async/dependency bookkeeping happens in generated code.opts.CodeGeneration.Sources.Add(...).LoadAsyncpattern — they coexist;IVariableSourceis the right choice when the value is created,LoadAsyncwhen it's retrieved.codegen preview).Closes
#2508
Test plan
docs/guide/codegen.mdrenders locally🤖 Generated with Claude Code