-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to private constructor with IncludedMembers in attribute #997
Comments
That should definitely be possible and would be a great addition to Mapperly. Would be happy to accept a PR implementing this. The constructor mapping is built in Contributing docs may give you a good introduction on how to contribute to Mapperly and about its tooling and architecture. |
Notes for the implementation:
Idea:
|
I would love to implement it, but, besides being an experienced developer I'm totally new to Code Generators, I briefly examined the code of Mapperly and I'm not sure I can implement it without proper guidance. |
Thank you in your interest implementing this. Currently we provide contributor documentation here. My recommendation would be to debug a few unit tests through the entire process. This helps you to get a general understanding on how things work (debugging Mapperly is described here). Let us know if you think anything is missing on the contribution docs or create a PR yourself to improve it 😊 |
Is your feature request related to a problem? Please describe.
Thanks for the new IncludedMembers features with private member mapping, I love it! What would put me over the moon though is if it could also use private constructors to initialise the object 😍
I'm not sure if that's possible at all, but I see the UnsafeAccessorKind-enum has a value for private constructors so I'm just guessing that it is possible somehow? Seems so from this blog post: https://www.meziantou.net/accessing-private-members-without-reflection-in-csharp.htm#constructors
Describe the solution you'd like
If I have a parameterless private constructor, the generated mapping code would still be able to initialise the object.
Describe alternatives you've considered
An alternative is exposing a public constructor of course, but I'm trying to map a database model to our domain models. The domain modal has explicit boundaries with Create-methods etc for our normal business code, but I'd still love to seamlessly map/project our domain model from database entities.
Additional context
https://github.com/riok/mapperly/assets/4932625/8037261c-a370-4e2a-898d-512fd16bd73b
The text was updated successfully, but these errors were encountered: