Skip to content

Non-unform mapping to get-only properties of a target interface  #374

Description

@andrei-traktatovich

Using Mapster 7,2,0, when mapping to an interface with both readonly and writeable properties results in readonly properties assigned default values. Mapping to an interface with readonly properties only results in readonly properties being populated with values from the source, e.g.

public interface ITarget // GetOnlyProperty will be assigned value from source
{
  int GetOnlyProperty {get;}
}
public interface ITargetWithGetSetProperties // GetOnlyProperty will be 0, GetSetProperty will be assigned value from source
{
  int GetOnlyProperty {get;}
  int GetSetProperty {get;set;}
}

Activity

  1. changed the title [-]Enable mapping to get-only properties of an interface [/-] [+]Non-unform mapping to get-only properties of a target interface [/+] on Sep 16, 2021
  2. andrei-traktatovich commented on Sep 16, 2021

    @andrei-traktatovich
    Author

    image

  3. andrei-traktatovich commented on Sep 16, 2021

    @andrei-traktatovich
    Author

    Seems like this behavior was introduced by this commit

    In my opinion, properties should be mapped regardless of whether an interface is completely "readonly" or not. Isn't a "readonly" interface simply an edge case of an interface which happens to lack writeable properties?

  4. self-assigned this
    on Feb 19, 2022
  5. added a commit that references this issue on Feb 20, 2022
    7384622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions