mapperly
mapperly copied to clipboard
Add OnlyExplicitMappedMembers implementation
Add OnlyExplicitMappedMembers Configuration Option
Description
First, I want to express my gratitude for the beautiful library and the excellent work that has been done in Mapperly. This library has been incredibly useful!
This PR introduces a new OnlyExplicitMappedMembers configuration option to the MapperAttribute that allows mapping only properties with explicit configurations (via attributes like MapProperty). All other properties will be ignored by default when this option is enabled.
This feature is particularly useful when working with classes that have many properties but you only need to map a few specific ones, providing a more declarative and maintainable approach compared to explicitly ignoring every unwanted property.
Changes made:
- Added
OnlyExplicitMappedMembersproperty toMapperAttribute - Added corresponding configuration to
MapperConfigurationand merger logic - Implemented the ignore logic in
IgnoredMembersBuilderto automatically ignore non-matching members when this option is enabled - Added comprehensive unit tests covering different scenarios (extra source members, extra target members, and extra members in both)
- Updated test infrastructure to support the new configuration option
Fixes #1981
Checklist
- [x] The existing code style is followed
- [x] The commit message follows our guidelines
- [x] Performed a self-review of my code
- [x] Hard-to-understand areas of my code are commented
- [ ] The documentation is updated (as applicable)
- [x] Unit tests are added/updated
- [ ] Integration tests are added/updated (as applicable, especially if feature/bug depends on roslyn or framework version in use)