Skip to content

Reverse / bidirectional mapping #246

Description

@sanelli

Summary

Support reverse / bidirectional mapping so a single configuration can map Source → Target and Target → Source, including unflattening of previously flattened members.

AutoMapper provides this via ReverseMap. Mapperly requires separate methods; Mappa should define an explicit, compile-time approach.

Current behavior

Mappa generates one-way maps only. There is no mechanism to derive or declare a reverse map from an existing partial method.

Proposed scope

  • Attribute or convention to declare a reverse companion map (or auto-generate when safe).
  • Reverse property/constructor parameter pairing consistent with forward map overrides (MappaUseProperty, etc.).
  • Integration with flattening/unflattening (#120) when nested paths are involved.
  • Clear diagnostics when reverse mapping is ambiguous or unsupported.

Acceptance criteria

  • Reverse/bidirectional maps can be declared and generated
  • Happy-path and negative-path generator tests
  • Documentation and samples
  • All tests pass via .\Scripts\RunTestsAndReportCoverage.ps1

Workflow notes

  • Plan file: .cursor/plans/issue_<N>_reverse_bidirectional_mapping.plan.md
  • Related to #120 for unflattening

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions