Allow passing parameters to projections and property mappings#1946
Allow passing parameters to projections and property mappings#1946Demivan wants to merge 3 commits into
Conversation
eba03ac to
0c6b907
Compare
552b8c1 to
845af2b
Compare
|
Thank you for the contribution. Before I dive into a detailed review, I think we should first align on the intended behavior. At the moment, Mapperly matches additional mapping parameters by name. I believe we should also match them by name when passing them to downstream mapping methods. How does your approach handle the following scenario: record A(ANested Nested);
record B(BNested Nested);
record ANested(int ValueA);
record BNested(int ValueB, int Ctx);
public partial B Map(A src, int ctx);Does this automatically generate |
|
@latonz All of these are valid use cases. I will investigate and fix them. |
|
These issues can be addressed in a separate PR (which might make more sense, otherwise this one could become too big). However, the overall concept of how everything should work needs to be clarified first. |
Sure.
In this PR, I match parameters by name and type. I think, it would make sense to match them only by name and map them if needed.
I didn't consider
Currently, this functionality does not work. And I think, it would be extremely tricky to do this automatically. Maybe it is better to only support this when mapping methods are manually defined. Currently, some diagnostics are incorrect. I'll fix those. |
|
Hi, thank you for opening this. I am also looking forward to this feature. When I was thinking about how to implement this, I thought to support only existing "extended" mapping: record A(ANested Nested);
record B(BNested Nested);
record ANested(int ValueA);
record BNested(int ValueB, int Ctx);
public partial B Map(A src, int ctx);
private partial BNested Map(ANested src, int ctx); // <-- this is mandatoryIf there is no |
|
Sounds good to me:
|
|
I’ve converted this PR to a draft. Please mark it as ready for review once it’s complete and request a review from me. Thank you! |
|
Sorry, I don't have time to continue with this right now. |
|
Thank you for your efforts anyway! |
Allow passing parameters to projections and property mappings
Description
This PR introduces parameter support for projections and property mappings:
Fixes #1472
Checklist