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.

Mapster.Tool incorrect codegen map to existing object

See original GitHub issue

Empty console project for .Net 6.0 with nullable enabled

public struct Source
{
    public string Name { get; set; }
}

public struct Dest
{
    public string Name { get; set; }
}

[Mapper]
public interface ITestMapping
{
    Dest AdaptTo(Source source, Dest dest);
}

Got next generated code:

public partial class TestMapping : ITestMapping
{
    public Dest AdaptTo(Source p1, Dest p2)
    {
        Dest result = new Dest();
        
        result.Name = p1.Name;
        return result;
        
    }
}

Parameter p2 doesn’t used. But expected next code

public partial class TestMapping : ITestMapping
{
    public Dest AdaptTo(Source p1, Dest p2)
    {
        p2.Name = p1.Name;
        return p2;
    }
}

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
andreravcommented, Jan 7, 2023

@heggi I’ve verified that this fixes the issue for both basic mapping and code generation. Please try version 8.4.0-pre05 and let me know how it goes:

dotnet tool install --global Mapster.Tool --version 8.4.0-pre05

0reactions
andreravcommented, Jan 9, 2023

Great, thank you! This fix will be included in Mapster.Tool 8.4.0 and Mapster 7.4.0 which should be released in a few weeks at the latest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MapsterMapper/Mapster: A fast, fun and stimulating object ...
There are currently two tools which you can choose based on your preferences. Mapster.Tool NEW! TextTemplate. Change logs. https://github.com/MapsterMapper/ ...
Read more >
Mapster.Tool use codegen to generate mappers but not ...
I don't believe you can use the tool to generate the mapping extension methods for existing entities however. At least im not aware...
Read more >
Seems that the [AdaptIgnore] attribute does not work as ...
Mapster.Tool incorrect codegen map to existing object #510 ... Hi @moghimi, may I ask which version of Mapster you are using?
Read more >
Mapster, the best .NET mapper that you are (probably) not using
It's a mapping library that it is packing some really amazing ... of existing mappers - 1:57 Simple mapping with Mapster - 6:04...
Read more >
Avoid reflections of mappers and let Mapster generate ...
#skip this step if you already have dotnet-tools.json dotnet new tool-manifest dotnet tool install Mapster.Tool. Add mapster to Application ...
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