Skip to content

Dedup DCB LoadBoundaryFrame per aggregate type on a chain - #2970

Closed
mysticmind wants to merge 2 commits into
mainfrom
fix/dedup-load-boundary-frame
Closed

mysticmind wants to merge 2 commits into
mainfrom
fix/dedup-load-boundary-frame

Conversation

@mysticmind

Copy link
Copy Markdown
Member

Two [BoundaryModel] parameters of the same type on one chain (e.g. Validate plus Handle) used to each add a LoadBoundaryFrame, emitting duplicate var eventBoundaryOf<TAggregate> = ... declarations and failing codegen with CS0128. Modify() now reuses an existing frame for the same aggregate type.

Regression test added in MartenTests/Dcb.

Two [BoundaryModel] parameters of the same type on one chain (e.g. Validate
plus Handle) used to each add a LoadBoundaryFrame, emitting duplicate
"var eventBoundaryOf<TAggregate> = ..." declarations and failing codegen with
CS0128. Modify() now reuses an existing frame for the same aggregate type.

Regression test added in MartenTests/Dcb.
Copilot AI review requested due to automatic review settings May 29, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Marten DCB code generation regression where multiple [BoundaryModel] parameters for the same aggregate type in one handler chain produced duplicate boundary loader declarations.

Changes:

  • Exposes LoadBoundaryFrame.AggregateType for matching existing loaders.
  • Reuses an existing Marten boundary loader for the same aggregate type instead of adding duplicates.
  • Adds a Marten regression test covering Validate + Handle with duplicate boundary model parameters.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Persistence/Wolverine.Marten/Codegen/LoadBoundaryFrame.cs Exposes aggregate type and uses it during generated boundary fetch code.
src/Persistence/Wolverine.Marten/BoundaryModelAttribute.cs Adds per-chain, per-aggregate deduplication for Marten boundary loader middleware.
src/Persistence/MartenTests/Dcb/dedup_load_boundary_frame_tests.cs Adds an end-to-end regression test for two [BoundaryModel] parameters on one chain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeremydmiller

Copy link
Copy Markdown
Member

Superseded by #2977, which keeps this dedup fix (with @mysticmind's commits retained as-authored) and adds the IL2062/IL2065/IL3050 trim suppressions on Wolverine.Polecat/BoundaryModelAttribute.Modify that the build + Polecat test jobs were failing on (matching the existing Marten sibling). Verified: Polecat builds clean on net9.0 + net10.0 and the full wolverine.slnx Release build is green.

@jeremydmiller

Copy link
Copy Markdown
Member

Closing in favor of #2977, which retains @mysticmind's commits and adds the trim-suppression fix for the failing CI build.

jeremydmiller added a commit that referenced this pull request May 29, 2026
Dedup DCB LoadBoundaryFrame per aggregate type on a chain (supersedes #2970)
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.

4 participants