Conversation
Tim-Maes
marked this pull request as draft
June 9, 2026 09:00
Tim-Maes
marked this pull request as ready for review
June 9, 2026 09:00
📦 Preview packages publishedVersion: Install with: This pre-release is published automatically from this PR and will be overwritten on the next push. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat:
[FacetMap]attribute for cross-assembly extension method mappingsProblem
In DDD architectures where DTOs live in a shared/contracts project (referenced by both frontend and backend), using
[Facet]causes type identity issues. C# treatsMyDtofrom Assembly A as a different type thanMyDtofrom Assembly B, even with identical namespace and class names. This leads to cast errors when crossing boundaries like SignalR hubs.Solution
A new
[FacetMap]attribute that generates extension methods for mapping between a source entity and an externally-defined target DTO. The DTO can be a plain POCO in any assembly with no Facet dependency.What's generated
For each
[FacetMap]marker class, Facet generates:To{Target}(this Source)To{Source}(this Target)GenerateToSource = true)ApplyTo{Source}(this Target, Source){Source}To{Target}ProjectionExpression<Func<Source, Target>>for LINQ/EF CoreSelectFacet generic projection support
FacetMap projections are now fully compatible with the generic
SelectFacet<TOut>()extension methods fromFacet.Extensions. This enables generic patterns like:Previously,
SelectFacetonly discovered projections defined directly on the target type (the[Facet]pattern). Since FacetMap targets are plain POCOs with no Facet dependency, their projections live on the marker class instead. A newFacetProjectionRegistryinFacet.Extensionsperforms automatic assembly scanning to discover these projections by convention.Features supported
[MapFrom]attribute for property name remapping[MapWhen]attribute for conditional mappingIFacetMapConfiguration)IFacetProjectionMapConfiguration)SelectFacet<TOut>()generic projection discovery[FacetMap]attributes on the same classCollectionTargetTypeoverrideGenerateToSource,GenerateProjection,MaxDepth)No breaking changes
[Facet]attribute or generatorSelectFacetchanges are backwards-compatible (existing[Facet]types use the fast reflection path; FacetMap discovery is only triggered as a fallback)Tagging issue #143