MapsterMapper / MapsterMapper/Mapster
[Improvement] - Add by default using optimum constructor selector to unify the choice of constructor for types
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 410
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Since the restriction of having a default constructor new() for classes is no longer mandatory,
and the constructor can using default values for the parameter type.
Optimality criterion(MappingScore) = maximum count of not mapped params. (MappingParam - CountParam)
If any constructors have the same MappingScore, select the one with more parameters.
Edge case: If any constructors have the same equal MappingScore and equal count of params select first.
Example:
Source
{
A
}
Destination
{
new () // MappingScore = 0; ParamCount = 0;
new (A) // MappingScore = 0; ParamCount = 1; <- select this max Param
}
Destination
{
new () // MappingScore = 0; ParamCount = 0; <- select this max MappingScore
new (A,В) // MappingScore = -1; ParamCount = 1;
}
Destination
{
new (A) // MappingScore = 0; ParamCount = 0; <- select this max MappingScore
new (A,В) // MappingScore = -1; ParamCount = 2;
}
Edge case:
Destination
{
new (A,B) // MappingScore = -1; ParamCount = 1; <- select this max MappingScore
new (A,C) // MappingScore = -1; ParamCount = 1;
}
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 by locating the constructor-selection and MappingScore logic in the Mapster source; the payload does not name specific files or tests. Add focused coverage for the stated score, parameter-count, and first-match tie-break rules, and consider the provided constructor examples done when they select the documented constructor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100