Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Diffract/Differ.fs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ module DifferImpl =
|> e.Accept
addNonRecursiveToCache differ cache
| Shape.Poco (:? ShapePoco<'T> as p) ->
let members = p.Properties |> Array.filter (fun p -> p.IsPublic)
let members = [|
for prop in p.Properties do if prop.IsPublic then prop
for field in p.Fields do if field.IsPublic then field
|]
addRecursiveToCache (diffReadOnlyFields<'T> custom members Diff.Record) cache
| Shape.Equality e ->
{ new IEqualityVisitor<IDiffer<'T>> with
Expand Down
21 changes: 21 additions & 0 deletions tests/Diffract.CSharp.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public void Poco()
Differ.ToString(expected, actual));
}

[Fact]
public void FieldPoco()
{
var expected = new MyFieldPoco(1, "a");
var actual = new MyFieldPoco(2, "a");
Assert.Equal("X Expect = 1\n Actual = 2\n",
Differ.ToString(expected, actual));
}

[Fact]
public void Record()
{
Expand Down Expand Up @@ -41,6 +50,18 @@ public class MyPoco
public MyInnerPoco Item { get; init; }
}

public class MyFieldPoco
{
public int X;
public string Y;

public MyFieldPoco(int x, string y)
{
X = x;
Y = y;
}
}

public record MyRecord(int X, string Y);
}
}
Loading