question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for mapping inner class

See original GitHub issue

Is your feature request related to a problem? Please describe. The internal class can correspond to properties declared as private set.

Describe the solution you’d like

record CarDto(string? Id);
partial class Car
{
    public string? Id { get; private set; }

    public void Update(CarDto dto)
    {
        Mapper1 mapper = new Mapper1();
        mapper.MergeCarDto(dto, this);
    }

    [Mapper(UseDeepCloning = true)]
    internal partial class Mapper1
    {
        public partial void MergeCarDto(CarDto source, Car target);
    }
}

Describe alternatives you’ve considered Currently using Automapper, but the performance is not optimal.

Additional context N.A.

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TimothyMakkisoncommented, Jul 30, 2023

Good find.

C# properties are two methods that mutate a private backing field ie <Id>k__BackingField. Mapperly is trying to map the two fields together. Not sure if this only happens with private set.

I’ll see if I can fix it later

0reactions
github-actions[bot]commented, Aug 7, 2023

🎉 This issue has been resolved in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mapstruct Mapping nested classes issue - java
I have found a solution: @Mapping(target = "nestedMember", source = ".") Target map(Input input); @Mapping(target = "bb", ...
Read more >
Mapping inner classes
Hi, I want to map properties of a class to another, which appears to be inner one. When the Impl class is generated,...
Read more >
Inner class does not allow maps
1 Answer. The issue is with the spellings of the access modifier for your second map in the inner class. Please change it...
Read more >
Add imports for inner classes given via @Mapper#imports()
When specifying an inner class via @Mapper#imports() which lives in the same package as the given mapper interface, that import is not added...
Read more >
Nested Classes - Learning the Java Language
Inner Classes ​​ As with instance methods and variables, an inner class is associated with an instance of its enclosing class and has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found