Open
Description
Background and motivation
To globally exclude member names from an equivalency assertion of a complex graph, one can use the IMemberInfo
overload as follows:
var ignoredPropertyNames = new[] { "Parent", "Children" };
actual.Should().BeEquivalentTo(expected, config => config
.Excluding((IMemberInfo member) => ignoredPropertyNames.Contains(member.Name)));
Please add a shortcut method that enables easily adding a list of properties to be excluded throughout the graph regardless of the type they belong to.
API Proposal
public abstract class SelfReferenceEquivalencyOptions<TSelf> : IEquivalencyOptions
{
public TSelf ExcludingMembersNamed(params string[] memberNames) =>
Excluding((IMemberInfo member) => memberNames.Contains(member.Name));
}
API Usage
actual.Should().BeEquivalentTo(expected, options => options.ExcludingMemberNames("Parent", "Children"));
Alternative Designs
No response
Risks
No response
Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?
Yes, please assign this issue to me.