MapsterMapper / MapsterMapper/Mapster
Behaviour of `IMapper.Map(src, dst)` differs from AutoMapper
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 410
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I discovered a difference between AutoMapper's and Mapster's implementation of the IMapper interface. Even though it could be argued that the AutoMapper behavior is unintuitive, I believe that for compatibility, Mapster should update the values of the destination object too.
**AutoMapper**
```c#
var output = mapper.Map(from, to);
// output and to contain the mapped values
```
**Mapster**
```c#
var output = mapper.Map(from, to);
// only output contains the mapped values
```
**Risk**
The risk that this issue poses is that usages like [here](https://github.com/AutoMapper/AutoMapper.Collection.EFCore/blob/e173021f8e29f54124503d25918b362686a8c851/src/AutoMapper.Collection.EntityFrameworkCore/Persistence.cs#L101) do not map the value after switching to the Mapster implementation of `IMapper`
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 at the IMapper.Map(src, dst) entry point and compare Mapster's behavior with the AutoMapper examples in the issue. Trace how the destination object is handled, then verify that both the returned value and the original destination contain the mapped values, ideally with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100