Is there anything like Automappers AssertConfigurationIsValid? #712
-
I am currently using Mapperly in a project and personally I am a big fan. But we have discovered a problem in the team - someone changed some code and an existing mapping stopped working because a property was renamed and stopped mapping. This was not obvious and took some time to discover since it was a part of the system not used daily. I have read the documents and tried google to see if there is anything like Automappers AssertConfigurationIsValid in Mapperly, but I didn't find it. Maybe there is a feature like this that I have missed? If there isn't already, we could really use a way of making sure no property is accidentally overstepped. A call to some validation function or an analysis rule that gives a build warning would be two great ways to achieve this. For us, writing unit tests for all mappings is probably not an option for us, I suspect that the team rather would migrate Automapper. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
There is no |
Beta Was this translation helpful? Give feedback.
-
Ah, thanks, works fine. I just had to explicitly state in |
Beta Was this translation helpful? Give feedback.
-
We solved this challenge by checking the generated mapping files into the git repository. Since Mapperly generates human-readable code, it’s very easy to spot mapping bugs due to renamed properties in the pull request diff view. |
Beta Was this translation helpful? Give feedback.
There is no
AssertConfigurationIsValid
because Mapperly emits diagnostics at compile time if a configuration has flaws. Have you tried using strict mappings?