Dogfooding 5.0 has revealed some inconsistent behavior of how Should().BeEquivalenTo should deal with value vs structural comparisons. This is currently governed by https://github.com/fluentassertions/fluentassertions/blob/release-5.0/Src/FluentAssertions/AssertionOptions.cs#L36 and https://github.com/fluentassertions/fluentassertions/blob/release-5.0/Src/FluentAssertions/Equivalency/ValueTypeEquivalencyStep.cs. I can think of two options that could fix this:
Equals and assume value semantics for that type. Add a method ComparingByMembers<T> (to counter ComparingByValue<T>) to override this behavior. Since we want to use anonymous types as an expectation, we should not treat those as value types.[FluentAssertions.HasValueSemantics] (by name, not by type)Any opinions?
I don't like the annotation option.
Agree, I also don't like to add annotations to production code, just for the specs.
I really feel that if you implement Equals yourself that we should trust that it is indeed equal.
Solved in #740
Most helpful comment
I don't like the annotation option.