I just discovered I get no errors if there is no mapping to a property if the source has a property with the same name. We are trying to make it as strict as possible and get errors when there are unmapped properties. It seems like Assert.IsConfigurationValid()
doesn't do that. Is there a way to make it work with stricter control?
Asked
Active
Viewed 787 times
1

Ufuk Hacıoğulları
- 37,978
- 12
- 114
- 156
-
2Why would the same property name on both source and destination types be an invalid configuration? Quite the opposite -- that's the convention Automapper uses. It would be more tedious (IMO) if you had to specific EVERY property. – PatrickSteele Dec 07 '11 at 17:14
-
@PatrickSteele There was a property which I overlooked in mappings. Property names were same on source and destination. It automatically mapped that property while it was supposed to be specifically ignored. It would be painful if that went to production unnoticed. It may be wrong but we want to map every property explicitly. It would be nice if AutoMapper came with that option too. – Ufuk Hacıoğulları Dec 07 '11 at 18:43
1 Answers
2
I dont believe that there is. I had a similar problem on a recent project.
What we did was ensure that every property on the target was specified in the mapping configuration in alphabetical order. Even if it was being ignored.
When errors occured it was possible to do a "visual" check of the target to see if any properties had been added / missed.

Remotec
- 10,304
- 25
- 105
- 147