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

Update lambdas #102

Closed axelheer closed 4 years ago

axelheer commented 4 years ago

Is there a way to complete lambdas too?

var result = context.Personen.Save(key, person =>
{
    |
});

A workaround would be to extract an update method first:

var result = context.Personen.Save(key, person =>
{
    Update(item, person);
});

And then let MappingGenerator do its magic within Update.

Having this magic within the lambda itself would come in very handy.

cezarypiatek commented 4 years ago

Hi, can you provide an example of the expected code that should be generated?

axelheer commented 4 years ago
var result = context.Personen.Save(key, person =>
{
    person.X = item.X;
    person.Y = item.Y;
});
cezarypiatek commented 4 years ago

Here's a pre-release version with the implementation of the requested feature https://ci.appveyor.com/api/buildjobs/8v29nu5lhugmgo5h/artifacts/MappingGenerator%2FMappingGenerator%2FMappingGenerator.Vsix%2Fbin%2FRelease%2FMappingGenerator.vsix

image

It also contains a couple of improvements for #101

Please let me know if everything works according to your expectations.

axelheer commented 4 years ago

102 as well as #101 work like a charm!

I've deleted some mapping code and was able to re-generate it using your tool. Except some business logic, calculations, aggregations and the like... of course. That should be a huge "dull-saver"!

Thanks a lot, I'm pumped. 😲

cezarypiatek commented 4 years ago

I've just made an official release with #102 and #101. Please install a new version from the marketplace to make sure you will get automatic updates/notifications in the future. https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator