question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MembersToInclude failure with List property

See original GitHub issue

Project info

<TargetFramework>netcoreapp2.2</TargetFramework>
...
<PackageReference Include="CompareNETObjects" Version="4.64.0" />

Classes

public class Parent {
    public List<Child> Children { get; set; }
}
public class Child {
    public bool BoolA { get; set; }
    public bool BoolB { get; set; }
}
...
Parent a = new Parent {
    Children = new List<Child> 
    {
        new Child {
	    BoolA = true,
	    BoolB = false
	},
	new Child {
	    BoolA = false,
	    BoolB = true
	}
    }
}
Parent b = new Parent {
    Children = new List<Child> 
    {
	new Child {
	    BoolA = false,
	    BoolB = true
	},
	new Child {
	    BoolA = true,
	    BoolB = false
	}
    }
}

AreEqual = false (as expected):

ComparisonConfig config = new ComparisonConfig()
CompareLogic compareLogic = new CompareLogic(config);
ComparisonResult result = _compareLogic.Compare(a, b);
//result.AreEqual = false (as expected)

AreEqual = true (bug):

ComparisonConfig config = new ComparisonConfig 
{
    MembersToInclude = new List<string>
    {
        "Children"
    }
};
CompareLogic compareLogic = new CompareLogic(config);
ComparisonResult result = _compareLogic.Compare(a, b);
//result.AreEqual = true (bug)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
GregFinzercommented, Dec 13, 2019

I have no idea. You will need to debug the source code. I wish I had never put in that feature. It is just all heartache.

1reaction
GregFinzercommented, Dec 11, 2019

This is by design. None of the child properties are included so they are not compared. You will also need to add Parent, Child, BoolA, and BoolB

Read more comments on GitHub >

github_iconTop Results From Across the Web

Group: Resource failing when using 'MembersToInclude' to ...
I have a DSC file with a resource hashtable configured similar to the following: Group AdminGroupMembership { Ensure = "Present" GroupName ...
Read more >
DSC GroupSet Resource - PowerShell
MembersToInclude, Use this property to add members to the existing membership of the group. The value of this property is an array of...
Read more >
DSC Group Resource - PowerShell
MembersToInclude, Use this property to add members to the existing membership of the group. The value of this property is an array of...
Read more >
FluentAssertions Should().BeEquivalentTo() fails with Lists ...
I suspect that the interface IDomainEvent is without any public properties. That explains the exception you're seeing, as the logic in ...
Read more >
DSC group resource can't remove domain user from local ...
Using either the MembersToExclude or MembersToInclude properties in the same configuration as this property will generate an error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found