Re:Show HN: Mapperly – A .NET source generator for object to...
by Idiot_in_Vain on Thursday January 12, 2023 @07:25AM
(#34352472)
What are the advantages over AutoMapper?
[ Parent
| on HN ]
Re:Show HN: Mapperly – A .NET source generator for object to...
by latonz on Thursday January 12, 2023 @07:30AM
(#34352533)
Automapper generates all mappings at runtime with reflection.
Mapperly in contrast uses roslyn based source generators and generates all mapping code at compile time. This leads to improved runtime performance with less allocations [1]. Since no reflection is used at runtime, the generated code is completely trimming save and AOT friendly.
Re:Show HN: Mapperly – A .NET source generator for object to...
by orra on Thursday January 12, 2023 @07:43AM
(#34352650)
Those are pretty compelling advantages. Thanks for sharing.
Re:Show HN: Mapperly – A .NET source generator for object to...
by mpawelski on Thursday January 12, 2023 @08:32AM
(#34353211)
And what's the advantages over Mapster? (haven't used it yet, but I see it's mentioned often as a "better Automapper" alternative)
Re:Show HN: Mapperly – A .NET source generator for object to...
by CommonGuy on Thursday January 12, 2023 @09:11AM
(#34353718)
Never used Mapster myself, but as far as I can see, Mapster does not provide a Roslyn based source generator. By default, it seems to create mappings at runtime (if not using the Mapster Tool to create mappings at build time).
Re:Show HN: Mapperly – A .NET source generator for object to...
by danbruc on Thursday January 12, 2023 @09:39AM
(#34354106)
Even though AutoMapper of course uses reflection to construct mappings, executing mappings does not involve reflection if not necessary. AutoMapper builds expression trees, compiles them on first use, and uses the resulting function to perform the mapping. If your mapping involves things only accessible through reflection, then the compiled mapping function will of course still have to rely on reflection.