Mapster.Tool incorrect codegen map to existing object
See original GitHub issueEmpty 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:
- Created 9 months ago
- Comments:11 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@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-pre05Great, 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.