v4.0
Migration guide from v3.6.0
- Strict mappings are enabled by default, either use
MapperAttribute.RequiredMappingStrategy
/MapperRequiredMappingAttribute
or revert to non-strict mappings (see strict mappings by default). - If the
ExplicitCast
conversion is disabled, disable the newEnumUnderlyingType
conversion too. - Members of foreach mappings are now mapped, which may result in additional members being mapped or new diagnostics being reported.
- To account for changed diagnostics adjust your
.editorconfig
as needed, see updated diagnostics. - The ordering of the member assignments in mappings may change, if you rely on the order of members being mapped, you may need to diff and verify the generated source code.
- Well-known .NET immutable types are not copied, even if
UseDeepCloning
is enabled. - For long property names, auto-flattening may not work anymore and may need to be configured manually by applying the
MapPropertyAttribute
.
Strict mappings by default
Starting with v4.0 Mapperly enables strict mappings by default with a severity of Warning
.
Either apply MapperAttribute.RequiredMappingStrategy
/MapperRequiredMappingAttribute
or
revert the change by setting the severity of RMG012
, RMG020
, RMG037
and RMG038
back to suggestion
.
See EditorConfig
on how to set the default severity of a given diagnostic.
Enum underlying type conversion
A new EnumUnderlyingType
conversion is added.
Whenever Mapperly tries to map from/to an enum and does not succeed,
Mapperly tries to map from/to the underlying type of the enum and explicitly cast the resulting value to the enum type.
Until v3.6.0 Mapperly used the ExplicitCast
to enable/disable this conversion.
Starting with v4.0 Mapperly introduces a new EnumUnderlyingType
conversion to enable/disable this conversion.
ForEach member mappings
ForEach mappings now also map members and constructor parameters the same way as regular object-to-object mappings. This may break existing code because a member that wasn't mapped before may now be mapped. New diagnostics can also be reported for existing mappings (e.g., if a new member is being mapped, but Mapperly cannot create a conversion for its types).
Limited auto-flattening
Mapperly tries to flatten properties automatically.
For this Mapperly tries to access object members based on the PascalCase member name notation of C#.
Starting with 4.0 Mapperly will only try up to 256 member path permutations.
Before all possible permutations were tried.
Auto-flattening can always be overwritten by applying the MapPropertyAttribute
.
Updated diagnostics
The following diagnostics are changed, removed or replaced.
You may need to update the .editorconfig
files and your Mapperly configuration code.
See EditorConfig
on how to set the default severity of a given diagnostic.
ID | Change |
---|---|
RMG009 | This is replaced by RMG083 for immutable types. For read only members RMG009 is used as in Mapperly v3. RMG009 is not emitted anymore for automatically matched read-only members. |
RMG012 | Starting with v4.0 Mapperly enables strict mappings by default with a level of warning . The default severity of RMG012: Source member was not found for target member changes from Info to Warning . |
RMG017 | RMG017: An init only member can have one configuration at max and RMG027: A constructor parameter can have one configuration at max are merged into the new RMG074: Multiple mappings are configured for the same target member |
RMG020 | Starting with v4.0 Mapperly enables strict mappings by default with a level of warning . The default severity of RMG020: Source member is not mapped to any target member changes from Info to Warning . |
RMG026 | RMG026: Cannot map from indexed member is removed, starting with 4.0 indexed members are ignored |
RMG027 | RMG017: An init only member can have one configuration at max and RMG027: A constructor parameter can have one configuration at max are merged into the new RMG074: Multiple mappings are configured for the same target member |
RMG028 | RMG028: Constructor parameter cannot handle target paths is removed as this is now supported. |
RMG037 | Starting with v4.0 Mapperly enables strict mappings by default with a level of warning . The default severity of RMG037: An enum member could not be found on the source enum changes from Info to Warning . |
RMG038 | Starting with v4.0 Mapperly enables strict mappings by default with a level of warning . The default severity of RMG038: An enum member could not be found on the target enum changes from Info to Warning . |