MapsterMapper / MapsterMapper/Mapster
Inheritance and scanning assembly for IRegister.
- 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
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 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