Skip to content

Fix source-created codegen variable reuse#392

Merged
jeremydmiller merged 1 commit into
JasperFx:mainfrom
erdtsieck:feature/issue-391
May 29, 2026
Merged

Fix source-created codegen variable reuse#392
jeremydmiller merged 1 commit into
JasperFx:mainfrom
erdtsieck:feature/issue-391

Conversation

@erdtsieck
Copy link
Copy Markdown
Contributor

Summary

Fixes #391.

This updates MethodFrameArranger so a variable source that returns a concrete variable for an interface request is reused later when the concrete type is requested. The arranger now considers already-known created variables and their sibling cast variables before asking the same source to create another frame.

Root Cause

In the tenanted Wolverine.HTTP + Marten path, one frame can first request IMessageBus/IMessageContext, causing the source to create a concrete MessageContext frame plus cast variables. Later the outboxed Marten session frame requests the concrete MessageContext. The arranger only looked at top-level method frames before invoking sources again, so it built a second MessageContext frame and generated a duplicate var messageContext declaration.

Tests

  • Added a regression test covering a source-created concrete context first requested through an interface and then requested by concrete type.
  • dotnet test src\CodegenTests\CodegenTests.csproj --no-restore

@erdtsieck erdtsieck marked this pull request as ready for review May 29, 2026 09:29
@jeremydmiller jeremydmiller merged commit 6a05765 into JasperFx:main May 29, 2026
1 check passed
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.

Codegen regression in 2.2.1: duplicate messageContext variable for tenanted Wolverine.HTTP + Marten endpoints (CS0128)

2 participants