cezarypiatek / MappingGenerator

:arrows_counterclockwise: "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator
MIT License
1.03k stars 120 forks source link

Generating mapping expression for C# 9 positional records #170

Open kszicsillag opened 3 years ago

kszicsillag commented 3 years ago

Feature description I am trying to generate mapping expressions between EF entity model and a DTO model. The DTO model consists of C#9 positional records. I could not generate proper DTO constructor for these expressions using any generation option.

The scenario is same as below, except filling a multi-parameter constructor instead of an initialization block as C# 9 positional records are initialized through constructor instead of initialization block. initialization block in lambda expression

Reasoning behind Generating expressions do work for initialization blocks. Generating pure mapping methods do work with positional records as mapping target. Generating expressions for positional records should work as well.

Real word example of the usage Positional record is an emerging new concept, expecting to see more DTO models implemented as positional records.

cezarypiatek commented 3 years ago

Hi @kszicsillag

Thanks for reporting this feature request. I will try to implement it but right now I can't promise any specific date. I will let you know when it's ready.

cezarypiatek commented 3 years ago

Hi @kszicsillag

This refactoring option is not using the constructor because it's strictly intended for completing the initialization blocks. In the case of regular mapping, a record primer constructor should be automatically picked up.

The new version of MappingGenerator contains a refactoring for generating this kind of lambda expression from the scratch. 6glQjkHLPn

If you have other problems with record types or any suggestion please report them in the new issue tracker https://github.com/cezarypiatek/MappingGeneratorIssueTracker