riok / mapperly

A .NET source generator for generating object mappings. No runtime reflection.

Home Page:https://mapperly.riok.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Local (mapping method level) for AllowNullPropertyAssignment

xontab opened this issue · comments

Is your feature request related to a problem? Please describe.
It looks like at the moment AllowNullPropertyAssignment is only accepted at Global (mapper level). Thus multiple mapper classes need to be created if AllowNullPropertyAssignment is only required for one mapping method.

Describe the solution you'd like
If possible a MapperAllowNullPropertyAssignment attribute can be introduced to allow adding this attribute at method level. This approach is similar to other configuration such as RequiredMappingStrategy.

[MapperAllowNullPropertyAssignment(false)]
public partial void MapCar(this Car source, CarDto target);

Additional context
If there are technical challenges to achieve this, the current solution of implementing multiple classes is still good enough.