Add OnlyExplicitMappedMembers implementation #2001
Closed
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.
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
OnlyExplicitMappedMembersconfiguration option to theMapperAttributethat allows mapping only properties with explicit configurations (via attributes likeMapProperty). 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:
OnlyExplicitMappedMembersproperty toMapperAttributeMapperConfigurationand merger logicIgnoredMembersBuilderto automatically ignore non-matching members when this option is enabledFixes #1981
Checklist