Add ability to specify own naming convention #854
Replies: 4 comments 10 replies
-
The problem with this is that the property mapping has to be done at compile time. This would mean that the property naming strategy code would have to be run at compile time, which would probably have a large performance impact and would probably also be unexpected (it is not intuitive to think of running the user code at compile time instead of at runtime). |
Beta Was this translation helpful? Give feedback.
-
It looks very reasonable, though I wonder if the approach allows addressing suffixes and prefixes differences. |
Beta Was this translation helpful? Give feedback.
-
Sure,
and I'm mapping them to some other models. Currently, I don't think that it's possible to make Mapperly to generate automatically
In the other systems, I saw that property names may have their type name as a suffix.
Having more control over the mapping convention makes the whole experience much more powerful. |
Beta Was this translation helpful? Give feedback.
-
I was just about to write an idea to add support for custom conventions (or kind of new PropertyNameMappingStrategy value that will handle it) , but it is already here. My case is (almost) the same as yours @StasPerekrestov. I need to map properties in snake case to pascal cast (and vice versa) and currently cannot be done easily. Need to map every single property with underscore. Have you been thinking about custom split char, so user can define it in attribute level? However I cannot see any other useful examples than underscore character. In the same way define prefix and suffix to ignore. |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to allow Mapperly users to specify their own naming convention?
Mapperly provides a way to have 2 mapping strategies only, however, there could be use cases when it's insufficient.
For instance, when integration with an "old" SOAP-based system happens, the code generated by
xsd.exe/svcutil
could havesuffixes/prefixes for every property, e.g.
XYZ_FIRST_NAME
. As you can see, the mapping might need to address prefixes, snake cases, and capitalization differences.What if Mapperly allows specifying strategy type explicitly?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions