Skip to main content

Analyzer diagnostics

Mapperly emits several diagnostics:

Rule IDSeverityDescription
RMG001ErrorA mapping method has an unsupported signature.
RMG002ErrorNo accessible parameterless constructor found.
RMG003WarningNo overlapping enum members found.
RMG004WarningIgnored target property not found.
RMG005ErrorMapping target property not found.
RMG006ErrorMapping source property not found.
RMG007ErrorCould not map property.
RMG008ErrorCould not create mapping.
RMG009InfoCannot map to read only property.
RMG010InfoCannot map from write only property.
RMG011InfoCannot map to write only property path.
RMG012InfoMapping source property not found.
RMG013ErrorNo accessible constructor with mappable arguments found
RMG014WarningCannot map to the configured constructor to be used by Mapperly
RMG015InfoCannot map to init only property path
RMG016ErrorInit only property cannot handle target paths
RMG017WarningAn init only property can have one configuration at max
RMG018ErrorPartial static mapping method in an instance mapper
RMG019ErrorPartial instance mapping method in a static mapper
RMG020InfoSource property is not mapped to any target property
RMG021WarningIgnored source property not found
RMG022ErrorInvalid object factory signature
RMG023ErrorMapping source property for a required target property not found
RMG024ErrorThe reference handler parameter is not of the correct type
RMG025ErrorTo use reference handling it needs to be enabled on the mapper attribute
RMG026InfoCannot map from indexed property
RMG027WarningA constructor parameter can have one configuration at max
RMG028ErrorConstructor parameter cannot handle target paths

Mapperly only emits updated source code on build. You won't see the updated mapper code or mapper diagnostics until you perform a build.

This is done for performance reasons, otherwise the IDE could become laggy. Improvements are tracked in #72.


The severity of these diagnostics can be customized via an .editorconfig file:

dotnet_diagnostic.{RuleID}.severity = error
dotnet_diagnostic.RMG020.severity = error

Strict mappings

To enforce strict mappings (all source properties have to be mapped to a target property and all target properties have to be mapped from a source property) set the following two editorconfig settings:

dotnet_diagnostic.RMG012.severity = error # Unmapped target property
dotnet_diagnostic.RMG020.severity = error # Unmapped source property