MapsterMapper / MapsterMapper/Mapster
Ignore in an Inherited Object
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
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 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