Skip to content

Conversation

@Kataane
Copy link
Contributor

@Kataane Kataane commented Jan 9, 2026

Add Reverse Mapping Support

Description

Implements reverse mapping functionality for Mapperly with a new Reverse property on IncludeMappingConfigurationAttribute. Automatically swaps source/target types and reverses member configurations for bidirectional mapping.

Key changes:

  • Added IReversible<T> interface pattern
  • Enhanced configuration reader with reverse logic
  • Comprehensive test coverage (9 scenarios)
  • Maintains backward compatibility

Fixes # (issue)

Checklist

  • Code style followed
  • Commit message follows guidelines
  • Self-review completed
  • Code commented where needed
  • Documentation updated
  • Unit tests added/updated
  • Integration tests added/updated

Example

[MapProperty(nameof(Product.Price), nameof(ProductDTO.PriceInEuro))]
public static partial ProductDTO ToDTO(this Product source);

[IncludeMappingConfiguration(nameof(ToDTO), Reverse = true)]
public static partial Product ToProduct(this ProductDTO source);

#1250

@Kataane
Copy link
Contributor Author

Kataane commented Jan 9, 2026

For some reason, the test failed after I merged the main branch to my branch :(

Update: this configuration no longer works.

[MapProperty(nameof(Product.Discounts.EndUsers), nameof(ProductDTO.Discount))]

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.

1 participant