Not all mapping errors are surfaced when a map contains more than one sort of misconfiguration #4524
Replies: 2 comments 3 replies
-
A PR is welcome. |
Beta Was this translation helpful? Give feedback.
3 replies
-
This discussion has been automatically locked since there has not been any recent activity after it was closed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When a map contains unmapped properties and properties with incompatible types, only the unmapped member error is thrown during validation. Once the unmapped member error is fixed, then the "unmappable member" error is thrown.
AssertConfigurationIsValid
should surface all mapping errors upfront, to prevent the need for multiple passes when fixing configuration errors.Example
This will throw this error:
When the unmapped member is mapped, the code will then start throwing this error:
I think it would be very helpful if the configuration exception showed both issues at once. I believe this could be done relatively easily by lifting the existing
configExceptions
collection higher in theAssertConfigurationIsValid
method and having it collect type map errors together with dry run errors.https://github.com/AutoMapper/AutoMapper/blob/b521096a3e05782df85fdb42356601a9bb3f35f8/src/AutoMapper/Configuration/ConfigurationValidator.cs#L28-L63
Beta Was this translation helpful? Give feedback.
All reactions