Skip to content

Fix ConfigureMarten not being called for projection view types#4157

Merged
jeremydmiller merged 1 commit intomasterfrom
fix/configure-marten-projection-view-types
Mar 3, 2026
Merged

Fix ConfigureMarten not being called for projection view types#4157
jeremydmiller merged 1 commit intomasterfrom
fix/configure-marten-projection-view-types

Conversation

@jeremydmiller
Copy link
Member

Summary

  • Fixes The 'ConfigureMarten' static method is not working correctly for MultiStreamProjection projections #4156 — the static ConfigureMarten method on a view type was never invoked when the type was registered only through a projection (e.g., MultiStreamProjection<TDoc, TId>)
  • Root cause: StorageFeatures.Build() used the non-generic DocumentMapping(Type, StoreOptions) constructor as a fallback, which skips the ConfigureMarten reflection lookup that only exists in the generic DocumentMapping<T> constructor
  • Fix: use DocumentMappingBuilder<T> (via CloseAndBuildAs) in the fallback path, which creates a DocumentMapping<T> that properly discovers and invokes ConfigureMarten

Test plan

  • Added regression test uses_ConfigureMarten_for_projection_view_type_registered_only_via_projection that verifies ConfigureMarten is called for a MultiStreamProjection view type
  • Confirmed test fails without the fix, passes with it
  • CoreTests pass (291 passed, 1 skipped)
  • DocumentDbTests pass (921 passed, 1 skipped, 4 flaky database failures that reproduce on the base branch)

🤖 Generated with Claude Code

When a document type was registered only through a projection (e.g.,
MultiStreamProjection), StorageFeatures.Build() used the non-generic
DocumentMapping constructor which skips the ConfigureMarten reflection
lookup. Now uses DocumentMappingBuilder<T> to ensure the generic
DocumentMapping<T> constructor is always used, which discovers and
invokes the static ConfigureMarten method.

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.

The 'ConfigureMarten' static method is not working correctly for MultiStreamProjection projections

1 participant