Skip to content

Dedup DCB LoadBoundaryFrame per aggregate type on a chain (supersedes #2970)#2977

Merged
jeremydmiller merged 3 commits into
mainfrom
fix/2970-polecat-boundary-trim
May 29, 2026
Merged

Dedup DCB LoadBoundaryFrame per aggregate type on a chain (supersedes #2970)#2977
jeremydmiller merged 3 commits into
mainfrom
fix/2970-polecat-boundary-trim

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Supersedes #2970 — same dedup fix, plus the trim-analysis fix the CI build needed. Original work and authorship by @mysticmind (commits retained as-authored); this branch only adds the AOT/trim suppression on top.

Original change (from #2970, @mysticmind)

Two [BoundaryModel] parameters of the same type on one chain (e.g. Validate plus Handle) each added 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.

CI fix added here

#2970's build and Polecat test jobs failed with:

src/Persistence/Wolverine.Polecat/BoundaryModelAttribute.cs(51,13): error IL2062:
Value passed to parameter 'type' of method 'TypeExtensions.Closes(Type, Type)'
can not be statically determined ...

Wolverine.Polecat is <IsAotCompatible> and treats trim warnings as errors. The aggregateType.Closes(typeof(IEventBoundary<>)) call (and the adjacent MakeGenericType / GetProperty) trip IL2062/IL2065/IL3050 under trim analysis. The sibling Wolverine.Marten/BoundaryModelAttribute.Modify already carries exactly these three suppressions for the identical reflection pattern; this adds the same to the Polecat attribute. The calls run at Dynamic-codegen time — AOT consumers pre-generate via TypeLoadMode.Static.

Verification

  • dotnet build src/Persistence/Wolverine.Polecat — clean on net9.0 and net10.0 (was the IL2062 failure).
  • Full dotnet build wolverine.slnx -c Release — 0 warnings, 0 errors (matches the failing build job).

Close #2970 in favor of this once merged.

mysticmind and others added 3 commits May 29, 2026 21:36
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.
The DCB LoadBoundaryFrame dedup change surfaced an IL2062 trim error at
BoundaryModelAttribute.cs:51 (`aggregateType.Closes(typeof(IEventBoundary<>))`)
because Wolverine.Polecat is `<IsAotCompatible>` and treats trim warnings as
errors — failing the `build` and Polecat `test` CI jobs.

Add the same trim/AOT suppressions the sibling Wolverine.Marten
BoundaryModelAttribute.Modify already carries for the identical reflection
pattern (Closes + MakeGenericType + GetProperty). These run at Dynamic-codegen
time; AOT consumers pre-generate via TypeLoadMode.Static.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 6d3db7a into main May 29, 2026
24 checks passed
This was referenced Jun 1, 2026
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.

3 participants