-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
When an object has it's own property with the same name as a property on an explicitly implemented interface, and the compile time type is the interface, and RespectingDeclaredTypes is used, the public property is used for comparison
Complete minimal example reproducing the issue
public interface IInterface
{
int Property { get; }
}
public class Implementation: IInterface
{
public int Property => 1;
}
public class Explicit: IInterface
{
int IInterface.Property => 1;
public int Property => 2;
}
[TestMethod]
public void TestMethod1()
{
IInterface impl = new Implementation();
IInterface expl = new Explicit();
expl.Should().BeEquivalentTo(impl, opts => opts.RespectingDeclaredTypes());
}Expected behavior:
Test passes
Actual behavior:
Error: Expected member Property to be 1, but found 2.
Versions
- Which version of Fluent Assertions are you using? master branch
- Which .NET runtime and version are you targeting? .NET Core 2.2
Additional Information
Note that using a member matching rule of:
public class ReflectionMemberMatchingRule : IMemberMatchingRule
{
public SelectedMemberInfo Match(SelectedMemberInfo expectedMember, object subject, string memberPath, IEquivalencyAssertionOptions config) => expectedMember;
}works as expected, but is obviously naive to mismatched types, etc.
I'd be happy to address this if someone can give me some guidance on where, and how to fix it.