Analyzer diagnostics
Mapperly emits several diagnostics:
| Rule ID | Severity | Description |
| RMG001 | Error | A mapping method has an unsupported signature. |
| RMG002 | Error | No accessible parameterless constructor found. |
| RMG003 | Warning | No overlapping enum members found. |
| RMG004 | Warning | Ignored target member not found. |
| RMG005 | Error | Mapping target member not found. |
| RMG006 | Error | Mapping source member not found. |
| RMG007 | Error | Could not map member. |
| RMG008 | Error | Could not create mapping. |
| RMG009 | Info | Cannot map to read only member. |
| RMG010 | Info | Cannot map from write only member. |
| RMG011 | Info | Cannot map to write only member path. |
| RMG012 | Warning | Source member was not found for target member |
| RMG013 | Error | No accessible constructor with mappable arguments found |
| RMG014 | Warning | Cannot map to the configured constructor to be used by Mapperly |
| RMG015 | Info | Cannot map to init only member path |
| RMG016 | Error | Init only member cannot handle target paths |
| RMG020 | Warning | Source member is not mapped to any target member |
| RMG021 | Warning | Ignored source member not found |
| RMG022 | Error | Invalid object factory signature |
| RMG023 | Error | Mapping source member for a required target member not found |
| RMG024 | Error | The reference handler parameter is not of the correct type |
| RMG025 | Error | To use reference handling it needs to be enabled on the mapper attribute |
| RMG029 | Error | Queryable projection mappings do not support reference handling |
| RMG030 | Error | Reference loop detected while mapping to an init only member |
| RMG031 | Warning | Reference loop detected while mapping to a constructor member |
| RMG032 | Warning | The enum mapping strategy ByName cannot be used in projection mappings |
| RMG033 | Info | Object mapped to another object without deep clone |
| RMG034 | Error | Derived source type is specified multiple times, a source type may only be specified once |
| RMG035 | Error | Derived source type is not assignable to parameter type |
| RMG036 | Error | Derived target type is not assignable to return type |
| RMG037 | Warning | An enum member could not be found on the source enum |
| RMG038 | Warning | An enum member could not be found on the target enum |
| RMG039 | Error | Enum source value is specified multiple times, a source enum value may only be specified once |
| RMG040 | Error | A target enum member value does not match the target enum type |
| RMG041 | Error | A source enum member value does not match the source enum type |
| RMG042 | Error | The type of the enum fallback value does not match the target enum type |
| RMG043 | Warning | Enum fallback values are only supported for the ByName and ByValueCheckDefined strategies, but not for the ByValue strategy |
| RMG044 | Warning | An ignored enum member can not be found on the source enum |
| RMG045 | Warning | An ignored enum member can not be found on the target enum |
| RMG046 | Error | The used C# language version is not supported by Mapperly, Mapperly requires at least C# 9.0 |
| RMG047 | Error | Cannot map to member path due to modifying a temporary value, see CS1612 |
| RMG048 | Error | Used mapper members cannot be nullable |
| RMG049 | Warning | Source member is ignored and also explicitly mapped |
| RMG050 | Warning | Target member is ignored and also explicitly mapped |
| RMG051 | Warning | Invalid ignore source member found, nested ignores are not supported |
| RMG052 | Warning | Invalid ignore target member found, nested ignores are not supported |
| RMG053 | Error | The flag MemberVisibility.Accessible cannot be disabled, this feature requires .NET 8.0 or greater |
| RMG054 | Error | Mapper class containing 'static partial' method must not have any instance methods |
| RMG055 | Error | The source type does not implement ToString with the provided formatting parameters, string format and format provider cannot be applied |
| RMG056 | Error | Invalid format provider signature |
| RMG057 | Error | Format provider not found |
| RMG058 | Error | Multiple default format providers found, only one is allowed |
| RMG059 | Error | Multiple default user mappings found, only one is allowed |
| RMG060 | Warning | Multiple user mappings discovered without specifying an explicit default |
| RMG061 | Error | The referenced mapping was not found |
| RMG062 | Error | The referenced mapping name is ambiguous |
| RMG063 | Error | Cannot configure an enum mapping on a non-enum mapping |
| RMG064 | Error | Cannot configure an object mapping on a non-object mapping |
| RMG065 | Warning | Cannot configure an object mapping on a queryable projection mapping, apply the configurations to an object mapping method instead |
| RMG066 | Warning | No members are mapped in an object mapping |
| RMG067 | Error | Invalid usage of the MapPropertyAttribute |
| RMG068 | Info | Cannot inline user implemented queryable expression mapping |
| RMG069 | Warning | Runtime target type or generic type mapping does not match any mappings |
| RMG070 | Error | Mapping nested member not found |
| RMG071 | Warning | Nested properties mapping is not used |
| RMG072 | Warning | The source type of the referenced mapping does not match |
| RMG073 | Warning | The target type of the referenced mapping does not match |
| RMG074 | Error | Multiple mappings are configured for the same target member |
| RMG075 | Error | Invalid usage of the MapValueAttribute |
| RMG076 | Warning | Cannot assign null to non-nullable member |
| RMG077 | Error | Cannot assign constant value because the type of the value does not match the type of the target |
| RMG078 | Error | Cannot assign method return type because the type of the value does not match the type of the target |
| RMG079 | Error | The referenced method could not be found or has an unsupported signature |
| RMG080 | Error | The MapValueAttribute does not support types and arrays |
| RMG081 | Error | A mapping method with additional parameters cannot be a default mapping |
| RMG082 | Warning | An additional mapping method parameter is not mapped |
| RMG083 | Info | Cannot map to read only type |
| RMG084 | Error | Multiple mappings are configured for the same source string |
| RMG085 | Error | Invalid usage of fallback value |
| RMG086 | Error | The source of the explicit mapping from a string to an enum is not of type string |
| RMG087 | Error | The target of the explicit mapping from an enum to a string is not of type string |
| RMG088 | Info | The attribute to build the name of the enum member is missing |
| RMG089 | Info | Mapping nullable source to non-nullable target member |
| RMG090 | Info | Mapping nullable source type to non-nullable target type |
| RMG091 | Error | Circular included mapping configuration detected |
| RMG092 | Error | Source type is not assignable to the included source type |
| RMG093 | Error | Target type is not assignable to the included target type |
info
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.
Editorconfig
The severity of these diagnostics can be customized via an .editorconfig file:
.editorconfig
[*.cs]
dotnet_diagnostic.{RuleID}.severity = error
dotnet_diagnostic.RMG020.severity = error
See also code analysis configurations and available severity levels.
Suppress diagnostics
See the Microsoft documentation on how to suppress diagnostics in C# here. In summary, you can use one of the following approaches:
- Use the
.editorconfigfile (for an entire file, directory or project, depending on the editorconfig scope)
dotnet_diagnostic.RMG066.severity = none - Use the
SuppressMessageAttribute(for a method)
[SuppressMessage("Mapper", "RMG066:No members are mapped in an object mapping")] - Use precompiler directives (for specific lines of code)
#pragma warning disable RMG066 // No members are mapped in an object mapping
#pragma warning restore RMG066 // No members are mapped in an object mapping