MapsterMapper / MapsterMapper/Mapster
Possible regression / changed behavior in v10: `CasesCount` no longer maps from `Cases.Count` automatically
A pull request for this has already been merged.
- #916 by @DocSvartz — merged
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 410
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Hi,
after upgrading Mapster from v7 to v10, I noticed a behavior change that used to work for us without explicit custom mapping.
## What changed
We have a destination/view model property like:
```csharp
public int CasesCount { get; set; }
```
and a source entity with a collection:
```csharp
public ICollection Cases { get; set; }
```
In Mapster v7, `CasesCount` was populated automatically (effectively from Cases.Count) even without any explicit .Map(...) configuration.
After upgrading to v10, the same property now gets value 0.
## Question
Was this behavior intentionally changed in v10?
- If yes, was it ever officially supported, or was it only incidental behavior?
- If no, could this be a regression?
## Minimal example
```csharp
public class Source
{
public ICollection Cases { get; set; } = new List
{
new Case(),
new Case(),
new Case()
};
}
public class Case
{
}
public class Destination
{
public int CasesCount { get; set; }
}
```
Expected: `CasesCount == 3`
Actual: `CasesCount == 0`
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 with the minimal Source, Case, and Destination example in the issue, then review merged pull request #916 for the relevant v10 behavior. Compare the result against the stated v7 expectation; done means the behavior is either confirmed and documented as intentional or covered by a regression fix and verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100