You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a working "existing target object" (void method) mapper for a type that contains a collection property. If I change the collection property to an init setter then the collection is not mapped any more. That makes no sense because it is mapped with a private setter or with no setter at all. So an init setter should also work.
To Reproduce
Steps to reproduce the behavior:
Paste the code from below.
Check the generated code. Notice that the collection is mapped.
Modify the commented line to have an init setter.
Notice that the collection is not mapped any more.
Notice that the message "RMG015 Cannot map from member Source.Subs of type ICollection to init only member path Target.Subs of type ICollection" is shown.
Change the property setter to private set. Notice that the collection is mapped again.
Even weirder: Change the property setter to private init and notice that it is also mapped. Only public init isn't.
Expected behavior init collection properties should be mapped just like private set (or private init) properties and properties without any setter are mapped.
Code snippets
publicclassSource{publicrequiredICollection<SourceSub> Subs {get;init;}}publicclassSourceSub{publicrequiredstringName{get;init;}}publicclassTarget{// Change this to an 'init' setter to reproduce.publicICollection<TargetSub> Subs {get;}=newList<TargetSub>();}publicclassTargetSub{publicrequiredstringName{get;set;}}[Mapper]publicstaticpartialclassMapper{publicstaticpartialvoidMapToEntity(Sourcesource,Targettarget);}
Environment (please complete the following information):
Mapperly Version: 3.1.0
.NET Version: 7.0.400
Target Framework: net7.0
IDE: Visual Studio 2022 17.7.1
OS: Windows 10
The text was updated successfully, but these errors were encountered:
Describe the bug
I have a working "existing target object" (void method) mapper for a type that contains a collection property. If I change the collection property to an
init
setter then the collection is not mapped any more. That makes no sense because it is mapped with a private setter or with no setter at all. So aninit
setter should also work.To Reproduce
Steps to reproduce the behavior:
init
setter.private set
. Notice that the collection is mapped again.private init
and notice that it is also mapped. Only publicinit
isn't.Expected behavior
init
collection properties should be mapped just likeprivate set
(orprivate init
) properties and properties without any setter are mapped.Code snippets
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: