Riok.Mapperly by Mapperly Contributors, Lars Tönz, Manuel Allenspach

<PackageReference Include="Riok.Mapperly" Version="4.0.0" />

 MapperAttribute

public class MapperAttribute : Attribute
Marks a partial class as a mapper.
public bool AllowNullPropertyAssignment { get; set; }

Specifies whether null values are assigned to the target. If true (default), the source is null, and the target does allow null values, null is assigned. If false, null values are never assigned to the target property. This is ignored for required init properties and IQueryable<T> projection mappings.

public bool AutoUserMappings { get; set; }

Whether to automatically discover user mapping methods based on their signature. Partial methods are always considered mapping methods. If true, all partial methods and methods with an implementation body and a mapping method signature are discovered as mapping methods. If false only partial methods and methods with a UserMappingAttribute are discovered. To discover mappings in external mappers ( UseMapperAttribute and UseStaticMapperAttribute) the same rules are applied: If set to true all methods with a mapping method signature are automatically discovered. If set to false methods with a UserMappingAttribute and if the containing class has a MapperAttribute partial methods are discovered.

Enabled conversions which Mapperly automatically implements. By default all supported type conversions are enabled. Eg. to disable all automatically implemented conversions:EnabledConversions = MappingConversionType.NoneEg. to disable ToString() method calls:EnabledConversions = MappingConversionType.All & ~MappingConversionType.ToStringMethod

public bool EnumMappingIgnoreCase { get; set; }

Whether the case should be ignored for enum mappings.

The default enum mapping strategy. Can be overwritten on specific enums via mapping method configurations.

Defines the strategy to use when mapping an enum from/to string. Can be overwritten on specific enums via mapping method configurations.

The ignore obsolete attribute strategy. Determines how ObsoleteAttribute marked members are mapped. Defaults to None.

Determines the access level of constructors that Mapperly will take into account.

public MemberVisibility IncludedMembers { get; set; }

Determines the access level of members that Mapperly will map.

public bool PreferParameterlessConstructors { get; set; }

Controls the priority of constructors used in mapping. When true, a parameterless constructor is prioritized over constructors with parameters. When false, accessible constructors are ordered in descending order by their parameter count.

Strategy on how to match mapping property names.

Defines the strategy used when emitting warnings for unmapped members. By default this is Both, emitting warnings for unmapped source and target members.

public bool ThrowOnMappingNullMismatch { get; set; }

Specifies the behaviour in the case when the mapper tries to return null in a mapping method with a non-nullable return type. If set to true an ArgumentNullException is thrown. If set to false the mapper tries to return a default value. For a String this is Empty, for value types default and for reference types new() if a parameterless constructor exists or else an ArgumentNullException is thrown.

public bool ThrowOnPropertyMappingNullMismatch { get; set; }

Specifies the behaviour in the case when the mapper tries to set a non-nullable property to a null value. If set to true an ArgumentNullException is thrown. If set to false the property assignment is ignored. This is ignored for required init properties and IQueryable<T> projection mappings.

public bool UseDeepCloning { get; set; }

Whether to always deep copy objects. Eg. when the type Person[] should be mapped to the same type Person[], when false, the same array is reused. when true, the array and each person is cloned.

public bool UseReferenceHandling { get; set; }

Enables the reference handling feature. Disabled by default for performance reasons. When enabled, an IReferenceHandler instance is passed through the mapping methods to keep track of and reuse existing target object instances.

public MapperAttribute()