ValeraT1982 / ObjectsComparer

C# Framework provides mechanism to compare complex objects, allows to override comparison rules for specific properties and types.
MIT License
352 stars 86 forks source link

DateTime? difference MemberPath returns PropertyName.Value #27

Closed cotepatrice closed 3 years ago

cotepatrice commented 3 years ago

Hi!

I tried comparing 2 Nullable DateTime. The comparison goes well, but in the "Differences" list, I get "MyPropertyName.Value" instead of just "MyPropertyName" in MemberPath.

You can easily reproduce this behavior by modifying TestClass.A. Change DateTimeProperty type for DateTime?. After that, you can use the ComparerTests.PropertyInequality to see the behavior by looking at the differences received from the CalculateDifferences call.

Do you think it would be possible to return the real property name here?

ValeraT1982 commented 3 years ago

Behavior you described is "by design". As I remember nullable types are structs with property "Value". It's what you see in the path.

Do you think it would be possible to return the real property name here? I don't think it's possible, but you can remove ".Value" from the MemberPath string