File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
tests/Diffract.CSharp.Tests Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,10 @@ module DifferImpl =
124124 |> e.Accept
125125 addNonRecursiveToCache differ cache
126126 | Shape.Poco (:? ShapePoco< 'T> as p) ->
127- let members = p.Properties |> Array.filter ( fun p -> p.IsPublic)
127+ let members = [|
128+ for prop in p.Properties do if prop.IsPublic then prop
129+ for field in p.Fields do if field.IsPublic then field
130+ |]
128131 addRecursiveToCache ( diffReadOnlyFields< 'T> custom members Diff.Record) cache
129132 | Shape.Equality e ->
130133 { new IEqualityVisitor< IDiffer< 'T>> with
Original file line number Diff line number Diff line change @@ -13,6 +13,15 @@ public void Poco()
1313 Differ . ToString ( expected , actual ) ) ;
1414 }
1515
16+ [ Fact ]
17+ public void FieldPoco ( )
18+ {
19+ var expected = new MyFieldPoco ( 1 , "a" ) ;
20+ var actual = new MyFieldPoco ( 2 , "a" ) ;
21+ Assert . Equal ( "X Expect = 1\n Actual = 2\n " ,
22+ Differ . ToString ( expected , actual ) ) ;
23+ }
24+
1625 [ Fact ]
1726 public void Record ( )
1827 {
@@ -41,6 +50,18 @@ public class MyPoco
4150 public MyInnerPoco Item { get ; init ; }
4251 }
4352
53+ public class MyFieldPoco
54+ {
55+ public int X ;
56+ public string Y ;
57+
58+ public MyFieldPoco ( int x , string y )
59+ {
60+ X = x ;
61+ Y = y ;
62+ }
63+ }
64+
4465 public record MyRecord ( int X , string Y ) ;
4566 }
4667}
You can’t perform that action at this time.
0 commit comments