MapsterMapper / MapsterMapper/Mapster

Feature request: also force all source properties to be in destination

Open
#551 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

improvement open for PR
Dominant language
C#
Stars
5.2k
Forks
410
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Thanks for a great and useful package!

We are using RequireDestinationMemberSource and it works well:

  • RequireDestinationMemberSource:
    "Forcing all destination properties to have a corresponding source member or explicit mapping/ignore" (source)

But we also have a need to check the other direction.
Is there any plans or would it be possible to introduce a new property:

  • RequireSourceMemberDestination:
    Force all source properties to have a corresponding destination member

One scenario is where there's a one-way mapping from a stored proc DAO to DTO. A field is added to the table, picked up and added to the DAO by the EF Core PowerTools Reverse Engineering Tool, but not added to the DTO because the programmer forgot. We would love to see it throw an error here to alert us that the new property need to also be added to the DTO (destination) because it's in the source (DAO).

Another scenario is where a property is added to a request for a Save() web method. It was added to the SL but the programmer fails to add it to the DTO (and DAO). It might appear as though this new property is being saved from the front-end. But it isn't because it's just ignored. We would love to see an error thrown here to alert us that it's not being passed down.

p.s. The property names always confuse me. Wouldn't this be better:

  • EveryDestinationPropertyMustBeInSource (existing property)
  • EverySourcePropertyMustBeInDestination (new property)
    Or even:
  • RequireAllDestinationPropertiesToBeInSource (existing property)
  • RequireAllSourcePropertiesToBeInDestination (new property)

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 the existing RequireDestinationMemberSource behavior and the linked Config validation & compilation documentation; compare how destination members are currently checked. Done means a source-to-destination validation option is defined and documented, with an error for unmapped source properties; the issue names no repository files or tests.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.