AutoMapper icon indicating copy to clipboard operation
AutoMapper copied to clipboard

No mapping in Edge when using withProfile or static initialize

Open KlausHans opened this issue 7 years ago • 3 comments

Hello,

we have an Angular 6 webapp and we use your automapper, thank you very much.

In a refactoring task we started to use the .withProfile functionality. I created the profiles in a seperate file/class. But after a while we discovered, that the automapper does not work in the Edge browser anymore.

I then tried to mimic the profiles by creating static functions, that only call automapper.createMap(); for the respective models. These functions get called in a initialize function, so the mappings are created once at a single place. Unfortunately this leads to problems with Edge again. It only works if the static methods get called in the component/service where the mapping happens. Interestingly, automapper does not complain about missing maps.

I think this sounds like some kind of context problem. But on the other hand the maps are global, aren't they? I import automapper-ts with import { } from 'automapper-ts'; I also tried import * as automapper from 'automapper-ts'; but this doesn't made a difference.

I don't know if this is a bug or if Edge is just not supported. Maybe the problem is in our app. Any information or suggestion is highly appreciated.

KlausHans avatar Oct 05 '18 10:10 KlausHans

Hi @KlausHans,

Thanks for reaching out. I am not aware of specific browser limitations. Based on what you suggest, could it be you did not actually load the profiles? AutoMapper is not yet built with a module system in mind, so extra files needed should be loaded by yourself...

Cheers, Bert

loedeman avatar Oct 05 '18 10:10 loedeman

Thank you for the quick answer. It works perfectly in Chrome, Firefox and Safari. In these browsers the models get mapped with the profile. I think the automapper initializing is correct. Maybe i have the time next week to provide a minimal Angular project. Would it help?

KlausHans avatar Oct 05 '18 11:10 KlausHans

That sure would help understanding the situation a lot! Of course, if you find a solution when creating a reproduction scenario, feel free to file a PR instead 😉.


From: KlausHans [email protected] Sent: Friday, October 5, 2018 1:29:13 PM To: loedeman/AutoMapper Cc: Bert Loedeman; Comment Subject: Re: [loedeman/AutoMapper] No mapping in Edge when using withProfile or static initialize (#54)

Thank you for the quick answer. It works perfectly in Chrome, Firefox and Safari. In these browsers the models get mapped with the profile. I think the automapper initializing is correct. Maybe i have the time next week to provide a minimal Angular project. Would it help?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/loedeman/AutoMapper/issues/54#issuecomment-427334178, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAVrPN7uIsskvnscIrf1lNAYDHVwz80Jks5uh0KJgaJpZM4XJ8-Z.

loedeman avatar Oct 05 '18 11:10 loedeman