cezarypiatek / MappingGenerator

:arrows_counterclockwise: "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator
MIT License
1.03k stars 120 forks source link

Dublicate assignement on virtual-override #129

Closed maleet closed 4 years ago

maleet commented 4 years ago
public class BaseModel
{
    public virtual string Expression { get; set; }
}
public class Target : BaseModel
{
    public override string Expression { get; set; }

    public Target Copy(Target target)
    {
        return new Target()
        {
            Expression = target.Expression,
            Expression = target.Expression
        };
    }
}

Generated code have dublicates - two Exporession assignements

maleet commented 4 years ago

Not related, but there's another bug-like code example:

public class Target
{
    public Other Type { get; set; }

    public Guid Ref { get; set; }
}
/// Generated:
public Target MapTarget(Target target)
{
    return new Target()
    {
        Type = MapOther(target.Type),
        Ref = new Guid(a: 0, b: 0, c: 0, d: 0, e: (byte)target.Ref.GetHashCode(), f: 0, g: target.Ref.ToString(), h: 0, i: 0, j: 0, k: 0),
        Expression = target.Expression
    };
}
cezarypiatek commented 4 years ago

Good catch! Thanks for reporting this issue.

cezarypiatek commented 4 years ago

@maleet should be fixed in v1.16.411 Please let me know if it's working as expected.