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

Auto ignore properties when Destination Class does not have that property #19

Closed
rmalveis opened this issue Nov 7, 2016 · 4 comments
Closed

Comments

@rmalveis
Copy link
Contributor

rmalveis commented Nov 7, 2016

Hi.
I was using this lib, but I'm missing this functionality.
How can I achieve this using current implementation?

Here is a testCase to clarify:

it('should ignore properties on source object missing on destination object type Definition', () => {
            // arrange
            class DestinationType {
                public keep: string = null;
            }

            var fromObject = {
                keep: true,
                remove: true
            };

            var fromKey = '{60D9DB56-D6E1-48FF-9BAC-0805FCAF91B7}';
            var toKey = '{AC6D5B97-9AE3-4267-BD60-A5FED17E541A}';

            automapper.createMap(fromKey, toKey).convertToType(DestinationType);

            // act
            var toObject = automapper.map(fromKey, toKey, fromObject);
            // assert
            expect(toObject).toBeDefined();
            expect(toObject.remove).not.toBeDefined();
        });

(Just adding this test case to your current set it fails).

I didn't waste too much time analyzing and I think I made simple-minded solution, but you can check it and please feel free to make it safer or toggleable...
Can I open a pull request for you with my changes?

In my current working project this feature is essential.

Cheers.

@loedeman
Copy link
Owner

loedeman commented Nov 9, 2016

Hi @rmalveis ! Thanks for creating this issue and your PR. I just merged the PR (kudoos for your work!). I am currently developing on a fix for the other open issue, which I am planning to push this week. This fix requires quite a lot of refactoring, therefore it is not yet ready to push with confidence ;) ... If you are okay with it, I would like to create one release solving both issues at once.

@rmalveis
Copy link
Contributor Author

Hey @loedeman !
Releasing this week sounds good!
Let me know when it comes live.

Cheers.

@loedeman
Copy link
Owner

Hi @rmalveis,

I just created release 1.8.0 (https://github.com/loedeman/AutoMapper/tree/1.8.0), which contains your merged PR. Please let me know if you encounter any issue (or create a PR to fix them if you feel like it ;-) ). Thanks!

Happy coding!

@rmalveis
Copy link
Contributor Author

Thanks! I'll update in my project... if something weird appear I'll let you know.... or fix it :D

Cheers.

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

No branches or pull requests

2 participants