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

[Help Request] Mapper fails to create instances #129

Closed
bslbckr opened this issue Apr 5, 2019 · 6 comments
Closed

[Help Request] Mapper fails to create instances #129

bslbckr opened this issue Apr 5, 2019 · 6 comments
Assignees
Labels

Comments

@bslbckr
Copy link

bslbckr commented Apr 5, 2019

Dear @SteveWilkes , I once again have a mapping problem, briefly shown in this fiddle: https://dotnetfiddle.net/6ufGhK

I'm using the new ToTarget<>() Method to specify the target. However, the target-classes do not offer a parameter-less constructor and hence I specify a more detailed mapping for the concrete case, where I give a constructor-parameter using ToCtor<>().

At the moment I'm not quite sure, whether or not the mistake is at my site. Could please have a quick look?

@SteveWilkes SteveWilkes self-assigned this Apr 5, 2019
@SteveWilkes SteveWilkes added the bug label Apr 5, 2019
@SteveWilkes
Copy link
Member

SteveWilkes commented Apr 5, 2019

Hello again! The constructor parameter configurations will need to come before the ToTarget<>() configurations so the mapper knows how to create the target types, but unfortunately even with that changed it's failing to figure out how to construct them, and throwing an exception.

I'll take a look and sort it out!

@bslbckr
Copy link
Author

bslbckr commented Apr 8, 2019

Unfortunately, the observed behavior does not change, even if I give an explicit factory-method for instance creation. I.E. WhenMapping.From<Source.SituationObject>().To<Target.SituationObject>().CreatesInstancesUsing(...)

@SteveWilkes
Copy link
Member

Yeah - it's nothing you're doing wrong - ToTarget includes a check that the configured type can be constructed, but it's not taking types with configured constructions into account correctly. I'll have it sorted out soon! :)

SteveWilkes added a commit that referenced this issue Apr 18, 2019
* Method renames / Extending typed ToTarget test, re: #129, #130

* Extending typed ToTarget test / Adding failing ToTarget mapping callback test / Compiling ConfigInfo.ToMappingData caller

* Improving MappingCreationContext ctors

* Moving MappingCreationContext logic into MappingCreationContext

* Tidying

* Removing unused method / Tidying

* Support for mapping callbacks within non-implementation pair, ToTarget mappings

* Support for implementation pair ToTarget configuration
Removing unnecessary package from EF2 Core test project

* Continued

* Tidying

* Fixing support for ToTarget data sources in repeated mappings

* Handling null configured implementation ToTarget data sources
@SteveWilkes
Copy link
Member

SteveWilkes commented Apr 19, 2019

This is fixed as of v1.4-preview2, which is available on NuGet. Here's a fiddle showing it working :)

Let me know how you get on! Thanks again for the feedback!

@SteveWilkes SteveWilkes added the in-preview A feature or bug fix exists in a preview release, and a full release will follow label Apr 19, 2019
@bslbckr
Copy link
Author

bslbckr commented Apr 24, 2019

Thanks for the fix, at first sight it looks good.

SteveWilkes added a commit that referenced this issue May 3, 2019
* v1.4-preview branch

* Bugs/issue129 (#131)

* Short-circuiting expression replacement when target and replacement are the same
* Specifically retrieving ToTarget data sources where required
* Returning existing arrays in ICollection.ToArray if possible

* Updating release notes

* Adding v1.4-preview NuGet package

* Bugs/issue130 (#132)

* Method renames / Extending typed ToTarget test, re: #129, #130

* Extending typed ToTarget test / Adding failing ToTarget mapping callback test / Compiling ConfigInfo.ToMappingData caller

* Improving MappingCreationContext ctors

* Moving MappingCreationContext logic into MappingCreationContext

* Tidying

* Removing unused method / Tidying

* Support for mapping callbacks within non-implementation pair, ToTarget mappings

* Support for implementation pair ToTarget configuration
Removing unnecessary package from EF2 Core test project

* Continued

* Tidying

* Fixing support for ToTarget data sources in repeated mappings

* Handling null configured implementation ToTarget data sources

* Updating to v1.4-preview2

* Features/configured source member validation (#134)

* Erroring if redundant matching source member is configured

* Improving configured data source validation
Support for same-typed configured data source for otherwise-unconstructable target members

* Fixing ToTarget complex type entry dictionary mapping, re: #133

* Skipping existing dictionary value checks when target is definitely unpopulated

* Code coverage changes / Tidying

* Updating to v1.4-preview3

* Fixing build

* Fixing complex type dictionary merging

* Updating release notes

* Updating to v1.4

* v1.4 NuGet package
@SteveWilkes SteveWilkes removed the in-preview A feature or bug fix exists in a preview release, and a full release will follow label May 3, 2019
@SteveWilkes
Copy link
Member

v1.4 is now on NuGet. Cheers! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants