MapsterMapper / MapsterMapper/Mapster

Ignore in an Inherited Object

Open
#953 6 comments 0 reactions 0 assignees View on GitHub

A pull request for this has already been merged.

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

Description

When a child mapping uses `.Inherits()`, ignored fields defined in the parent config cannot be re-mapped in the child config.

**Parent mapping:**
```csharp
config.NewConfig()
.Ignore(dest => dest.LastModified);
```

**Child mapping:**
```csharp
config.NewConfig()
.Inherits()
.Map(dest => dest.LastModified, src => src.LastModified);
```

**Expected:** `AdvancedDTO.LastModified` is mapped from `Advanced.LastModified`.

**Actual:** `AdvancedDTO.LastModified` is ignored, inherited behavior overrides the child `.Map()` call.

**Proposed fix:** Add an `.Unignore(dest => dest.LastModified)` method, or ensure that an explicit `.Map()` on the child config takes precedence over a parent `.Ignore()`.

---

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 from the parent and child mapping examples in the issue and inspect how inherited Ignore rules and child Map calls are handled. Reproduce the case, then verify that the child mapping produces AdvancedDTO.LastModified from Advanced.LastModified without breaking inherited ignores.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.