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

MapProperty Use mapping function with existing object #1700

Open
johnnyelwailer opened this issue Jan 24, 2025 · 1 comment
Open

MapProperty Use mapping function with existing object #1700

johnnyelwailer opened this issue Jan 24, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@johnnyelwailer
Copy link

Is your feature request related to a problem? Please describe.
According to the docs I can define user mapping function allowing me to use the existing object: https://mapperly.riok.app/docs/configuration/existing-target/

E.g. in my case I tried this:

private void MapDocuments(DocumentDto[] target, [MappingTarget] ICollection<Document> source)
{
    ...
}

Then the MapProperty attribute allows us to define a custom mapper function like:

[MapProperty(nameof(MyEntityDto.Documents), nameof(MyEntity.Documents), Use = nameof(MapDocuments))]
public partial void Map(MyDto dto, [MappingTarget] MyEntity entity);

However above use case fails with the error: "RMG061: The referenced mapping named MapDocuments was not found"

Describe the solution you'd like
MapProperty should allow us to use void methods that require the existing object.

Additonally:
In my specific case above I am using collection types. Initially I expected the MapDocuments method to be automaticly used as a UserMapping, without actually declaring MapProperty, but it never used my method, even when using the classic signature: ICollection<Document > Map(DocumentDto[] dtos) {...}

Additional context
Not sure if it's a feature or bug.

@johnnyelwailer johnnyelwailer added the enhancement New feature or request label Jan 24, 2025
@latonz
Copy link
Contributor

latonz commented Jan 27, 2025

Thanks for bringing this up, this is not yet supported...

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

No branches or pull requests

2 participants