MapsterMapper / MapsterMapper/Mapster
wish to add the ability to ignore a copy of a property when it has a specific value. For example, null, empty string, empty collection
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 410
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
mapster has provided the function of not copying the property when the value of the property is null. Can we extend this function to stop copying the property when the value of the property is a series of specific values? It is better to provide a general method (I am not sure which property and which type, but I am sure that the value cannot be these)? Determine whether a property field can be copied before it is copied
``` C#
// Can you provide such a method
// Another framework, automapper, already provides similar functionality
// I don't care about the attribute name, but I care about the attribute value, and providing the attribute name is best when determining the attribute value
IgnoreMember((srcMember, destMember, srcValue, destValue) =>
{
if (srcValue is string srcValueTxt)
{
return string.IsNullOrWhiteSpace(srcValueTxt);
}
if (srcValue == destValue)
{
return true;
}
return false;
})
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing Mapster's existing behavior for not copying null properties and the IgnoreMember API shown in the issue. Define how configured values such as null, empty strings, and empty collections should affect copying, then verify the behavior with mapping cases covering the requested values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100