Skip to content

Possible regression / changed behavior in v10: CasesCount no longer maps from Cases.Count automatically #915

@NikolayIT

Description

@NikolayIT

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:

public int CasesCount { get; set; }

and a source entity with a collection:

public ICollection<Case> 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

public class Source
{
    public ICollection<Case> Cases { get; set; } = new List<Case>
    {
        new Case(),
        new Case(),
        new Case()
    };
}

public class Case
{
}

public class Destination
{
    public int CasesCount { get; set; }
}

Expected: CasesCount == 3
Actual: CasesCount == 0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions