mapperly
mapperly copied to clipboard
Raise diagnostic for memberpaths that mistakenly specify the type name
A common mistake with MapProperty is to include the type name as part of the string. This usually occurs when mapping a deeply nested property and the user removes nameof and adds parentheses. Mistakenly adding the enclosing type name to the path.
Note that C# does not allow properties to have the same name as the enclosing type.
public record Dog(Tail tail);
public record Tail(Colour colour);
// Diagnostic should be emitted because the first member path has the same name as the type
[MapProperty("Colour", "Dog.Tail.Colour")]
public static partial Dog Map(Table src);
This should probably also check MapperIgnoreTarget etc .
See #1030