Skip to content

Comments

Fix EntityAttribute codegen for value type identities (GH-2207)#2208

Merged
jeremydmiller merged 1 commit intomainfrom
GH2207
Feb 17, 2026
Merged

Fix EntityAttribute codegen for value type identities (GH-2207)#2208
jeremydmiller merged 1 commit intomainfrom
GH2207

Conversation

@jeremydmiller
Copy link
Member

Summary

  • ThrowRequiredDataMissingExceptionFrame unconditionally generated identity?.ToString() with the null-conditional operator, which is invalid C# for value types like Guid, int, long — causing a CS0023 compile error
  • Now checks Identity.VariableType.IsValueType to emit .ToString() for value types and ?.ToString() ?? "" for reference types
  • Regression was introduced in Fix completed saga from static Start still being persisted #2147 (v5.15.0)

Test plan

  • 3 new tests in MartenTests for [Entity(OnMissing = OnMissing.ThrowException)] with Guid identity
  • Full MartenTests: 331 passed, 2 failed (pre-existing durability flakes)
  • Full Wolverine.Http.Tests: 497 passed, 1 failed (pre-existing Bug_2182), 10 skipped — no regressions

Closes #2207

🤖 Generated with Claude Code

ThrowRequiredDataMissingExceptionFrame unconditionally generated the
null-conditional operator (?.) on the identity variable's ToString(),
which is invalid C# for value types like Guid, int, long. Now checks
IsValueType to emit .ToString() for value types and ?.ToString() for
reference types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Generated code does not compile for EntityAttribute on Guid property with OnMissing.ThrowException

1 participant