cezarypiatek / MappingGeneratorIssueTracker

This is a issue tracker for MappingGenerator
2 stars 0 forks source link

Add a way to generate DTO properties #9

Closed miniragnarok closed 1 year ago

miniragnarok commented 2 years ago

It would be a great feature if properties could be generated for a DTO from another class as a part of the complete mapping feature.

cezarypiatek commented 2 years ago

For now, you can try to use the [TwinType] attribute from my other package along with the corresponding code fix

More details in this article https://cezarypiatek.github.io/post/csharp-twin-types/

karlra commented 1 year ago

Agreed, this would be a great feature, being able to create an empty class, adding a constructor with the source class instance and then alt-enter -> create all the properties, mapped.

cezarypiatek commented 1 year ago

Hi @miniragnarok , @karlra

What are your expectations regarding mapping complex properties? Should the generated property have the same type or a new type should be generated for it?

karlra commented 1 year ago

Same type. Even if it just works for simple types it would still save a huge amount of typing.

cezarypiatek commented 1 year ago

I've started working on this feature. It will be fun ;)

karlra commented 1 year ago

Nice! I thought this feature existed in the plugin, it was why I bought it in the first place so thanks for that :)

cezarypiatek commented 1 year ago

I have a working POC. I will try to ship a basic implementation next week.

ubgmkMRQ8f

cezarypiatek commented 1 year ago

Hi @miniragnarok , @karlra

I've just released a new version 2023.1.51 with a basic implementation of the requested feature. Any feedback you can give me is welcome.

devenv_vLhaAzsQcL

karlra commented 1 year ago

It's perfect except for one thing, could we get an option to generate properties above the constructor instead of below? :)

cezarypiatek commented 1 year ago

Currently, the properties are added at the end of the type definition. I can tweak it a little bit to match the conventions. Thanks for the feedback.

cezarypiatek commented 1 year ago

This should be fixed in v2023.1.52. Please let me know if it's working according to your expectations.

karlra commented 1 year ago

Works great! Thank you!