File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1- using System ;
2- using Microsoft . VisualStudio . TestTools . UnitTesting ;
1+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
32using Shouldly ;
3+ using System ;
4+ using System . Collections . Generic ;
45using Assert = Microsoft . VisualStudio . TestTools . UnitTesting . Assert ;
56
67namespace Mapster . Tests
@@ -78,12 +79,40 @@ public class ModelDto
7879 public string SubSubSubCoolProperty { get ; set ; }
7980 }
8081
82+ public class Source915
83+ {
84+ public ICollection < Case > Cases { get ; set ; } = new List < Case >
85+ {
86+ new Case ( ) ,
87+ new Case ( ) ,
88+ new Case ( )
89+ } ;
90+ }
91+
92+ public class Destination915
93+ {
94+ public int CasesCount { get ; set ; }
95+ }
8196
8297 #endregion
8398
99+
84100 [ TestClass ]
85101 public class WhenFlattening
86102 {
103+
104+ /// <summary>
105+ /// https://github.com/MapsterMapper/Mapster/issues/915
106+ /// </summary>
107+ [ TestMethod ]
108+ public void FlatteningUsingSourceInterface ( )
109+ {
110+ var source = new Source915 ( ) ;
111+ var result = source . Adapt < Destination915 > ( ) ;
112+
113+ result . CasesCount . ShouldBe ( source . Cases . Count ) ;
114+ }
115+
87116 [ TestMethod ]
88117 public void GetMethodTest ( )
89118 {
Original file line number Diff line number Diff line change @@ -116,8 +116,7 @@ public static class ValueAccessingStrategy
116116 return member . GetExpression ( source ) ;
117117
118118 var propertyType = member . Type ;
119- if ( propertyName . StartsWith ( sourceMemberName ) &&
120- ( propertyType . IsPoco ( ) || propertyType . IsRecordType ( ) ) )
119+ if ( propertyName . StartsWith ( sourceMemberName ) && ! propertyType . IsMapsterPrimitive ( ) )
121120 {
122121 var exp = member . GetExpression ( source ) ;
123122 var ifTrue = GetDeepFlattening ( exp , propertyName . Substring ( sourceMemberName . Length ) . TrimStart ( '_' ) , arg ) ;
You can’t perform that action at this time.
0 commit comments