Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping from Interface to concrete class no longer works as expected #1598

Closed
jgilm opened this issue Aug 5, 2016 · 3 comments · Fixed by #1601
Closed

Mapping from Interface to concrete class no longer works as expected #1598

jgilm opened this issue Aug 5, 2016 · 3 comments · Fixed by #1601

Comments

@jgilm
Copy link

jgilm commented Aug 5, 2016

In Automapper 4.2.1 mapping from an Interface to a concrete class worked so that if a null property defined as an Interface would map to a concrete class as null.

In Automapper 5.0.2 a null interface property maps to a default constructed concrete class.

This is a breaking issue for my application. I have a lot of interface properties on source classes mapping to concrete class properties in the destination class.

Expectation:
I would expect that null properties on the source would map to null properties on the destination.

To test:
Gist

  • Make new console app, paste in gist
  • install Automapper 4.2.1 package and run console app. Test passes.
  • install Automapper 5.0.2 package and run console app. Test fails.

Although test is a console app, issue also occurs in a UWP app.

4.2.1 output:
image

5.0.2 output:
image

@jgilm
Copy link
Author

jgilm commented Aug 5, 2016

Another person found this same issue and posted it on StackOverflow, but no answers.

@alex-davidson
Copy link

Excellent, thank you! This issue was blocking our upgrade from Automapper 3.

@lock
Copy link

lock bot commented May 7, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants