Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent mapping for MapProperty when Source or Target properties are ignored #450

Closed
TimothyMakkison opened this issue May 21, 2023 · 0 comments · Fixed by #392
Closed
Labels
bug Something isn't working
Milestone

Comments

@TimothyMakkison
Copy link
Collaborator

TimothyMakkison commented May 21, 2023

Describe the bug
MapProperty maps MapperIgnoreSource properties but will not map MapperIgnoreTarget properties.

To Reproduce

[Mapper]
public static partial class Mapper
{
    [MapperIgnoreSource("Value")]
    // [MapperIgnoreTarget("Dest")]
    [MapProperty("Value", "Dest")]
    public static partial B IgnoredSource(A src);

    // [MapperIgnoreSource("Value")]
    [MapperIgnoreTarget("Dest")]
    [MapProperty("Value", "Dest")]
    public static partial B IgnoredTarget(A src);
}
public record A
{
    public int Value { get; set; }
}
public record B
{
    public int Dest { get; set; }
}
public static partial global::B IgnoredSource(global::A src)
{
    var target = new global::B();
    target.Dest = src.Value;
    return target;
}

public static partial global::B IgnoredTarget(global::A src)
{
    var target = new global::B();
    return target;
}

Expected behaviour
Mapperly should either not map when MapperIgnoreTarget is used or it should map when mapping from an ignored source property.
If we change Mapperly to map ignored properties then it should create a warning stating that ignoring the property is unneeded and has been overwritten.

TimothyMakkison added a commit to TimothyMakkison/mapperly that referenced this issue May 21, 2023
@latonz latonz added the bug Something isn't working label May 22, 2023
@latonz latonz added this to the v2.9.0 milestone Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants