MapsterMapper / MapsterMapper/Mapster

Inheritance and scanning assembly for IRegister.

Open
#726 5 comments 2 reactions 0 assignees View on GitHub

@DocSvartz is already working on this.

Since Jul 14, 2025.

  • #809 by @DocSvartz — open
improvement
Dominant language
C#
Stars
5.2k
Forks
410
Avg merge
2d 12h
Merged PRs (30d)
6

Description

If you use IRegister to define the inheritance mapping like this:

DerivedPocoProfile.cs

public class DerivedPocoProfile : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        .NewConfig<DerivedPoco, DerivedDto>()
        .Inherits<SimplePoco, SimpleDto>();
    }
}

SimplePocoProfile.cs

public class SimplePocoProfile : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        .NewConfig<SimplePoco, SimpleDto>();
    }
}

and then use scan assembly for types:

TypeAdapterConfig.GlobalSettings.Scan(typeof(DerivedPocoProfile).Assembly);

there is no guarantee that the base type will be registered first and

.Inherits<SimplePoco, SimpleDto>();

will fail silently, leaving your mapping inconsistent.

The current implementation of Inherits does nothing and simply returns when the type tuple has not yet been registered.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with TypeAdapterConfig.GlobalSettings.Scan and the IRegister/Inherits implementation described in the issue. Trace what happens when the derived registration is encountered before the base tuple, and verify that scanning order no longer silently loses the inheritance mapping. An open linked pull request indicates that work is already underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.