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

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

Closed
andrei-traktatovich opened this issue Sep 16, 2021 · 2 comments · Fixed by #375
Closed

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

andrei-traktatovich opened this issue Sep 16, 2021 · 2 comments · Fixed by #375
Assignees
Labels

Comments

@andrei-traktatovich
Copy link

andrei-traktatovich commented Sep 16, 2021

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;}
}
@andrei-traktatovich andrei-traktatovich changed the title Enable mapping to get-only properties of an interface Non-unform mapping to get-only properties of a target interface Sep 16, 2021
@andrei-traktatovich
Copy link
Author

image

@andrei-traktatovich
Copy link
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?

@andrerav andrerav self-assigned this Feb 19, 2022
@andrerav andrerav added the bug label Feb 19, 2022
andrerav added a commit that referenced this issue Feb 20, 2022
…y-props-in-non-readonly-interface

Init read-only properties when mapping with a non-readonly interface fixes #374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants