Skip to content

PR #26 introduced exclude bug #27

@digitaldirk

Description

@digitaldirk

@replaysMike @MohammadHadi2031 Thank you for the fast PR and Merge, but I believe that #26 introduced a bug :(. Nested exclude strings not do not exclude the properties now.

I have complex objects that have nested collection properties, I use a list of strings to exclude certain properties (".positions.name", ".positions.locations.id",...) but now they are not excluded, only ones like ".Id", ".Name" correctly exclude.

Here is a simple test that passes on fe9c29f (Previous latest version) but fails on d03f685 (Latest version)
.Id is excluded correctly, but .Bs.Name is not

[Test]
public void ExcludeByStringTest()
{
    var B1s = new List<B> { new B { Id = 10, Name = "Test 10" }, new B { Id = 11, Name = "Test 11" } };
    var B2s = new List<B> { new B { Id = 10, Name = "Test 10" }, new B { Id = 12, Name = "Test 12" } };
    var A1 = new A();
    A1.Id = 1;
    A1.Bs = B1s;
    var A2 = new A();
    A1.Id = 2;
    A2.Bs = B2s;

    var diff = A1.Diff(A2, propertiesToExcludeOrInclude: new string[] { ".Bs.Name", ".Id"});

    Assert.AreEqual(1, diff.Count);
}

class A
{
    public List<B> Bs { get; set; } = new List<B>();
    public int Id { get; set; }
}

class B
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions