UserMapping Scope #1938
Closed
randellhodges
started this conversation in
Ideas
Replies: 1 comment
-
|
We won’t add support for this directly in Mapperly since it’s more business logic than mapping logic. Mapperly’s goal is to focus on generating type-safe mappings, and transformations like enforcing If you really want to do it in the Mapperly, #451 could simplify it (would allow to implement a generic collection to collection user implemented mapping). At the same time, this does look like a fairly edge case with limited usage outside of scenarios like yours. That’s why we’d prefer to keep the core of Mapperly simple. |
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.
-
This is probably an edge case with limit use.
I have a few mappings I'm converting from Automapper that makes use of the AddTransform feature. For example:
.AddTransform<ICollection<string>>(collection => collection.DistinctAndSort());So, after mapping, it basically ensures that the collection is sorted and distinct. I understand it would be better to ensure that happens before it makes it this far, but that is another conversation :)
I know that I could do a
[UserMapping(Default = true)]but I don't want to do that for every ICollection in the mapping.I could do a
[MapProperty(..., ..., Use = nameof(SomeMethod))], but then I'd be doing that dozens of times and if I add another ICollection to that object, I'd have to remember to map that.I was thinking, would there be other uses for something like
[UserMapping(Scope = "SomeName")]and then you could apply an attribute like[MapScope("SomeName")]so that only those that match the scope would get applied to that instance of the mapping.A few things that would make this not worth implementing:
Just an idea to avoid having to put a dozen attributes on my partial mapper definition.
Beta Was this translation helpful? Give feedback.
All reactions