Generator.Equals icon indicating copy to clipboard operation
Generator.Equals copied to clipboard

Feature Request: Would be great to be able to enumerate the properties that are different!

Open Simonl9l opened this issue 1 year ago • 5 comments

Would be great to have a wrapper class such that one can have a Comparer collect the difference between say two record's or other supported type. This would also walk the nested collection and say use a ., [x] or => notation for the hierarchy, array/set elements or maps.

A Use Case: CDC you have the before and after image from your database of choice and need detect what changes happen between them, so some conditional biz logic can be applied based upon that.

That this generator avoids reflection means it will also work with AoT compilation.

Simonl9l avatar Mar 14 '23 05:03 Simonl9l

I haven't got much time recently to invest in new features. I will keep this here in case someone has a view on how this would be implemented/used.

diegofrata avatar Apr 23 '23 22:04 diegofrata

I'd love to attempt this. Would be a very nice feature, would help when debugging aswell 👍🏼

Will get back when I have a working example/PR.

Nickztar avatar Aug 10 '23 09:08 Nickztar

How do you show the difference between string? Do a Myers diff? What about byte[] or string[]? And is char[] treated as a string? Then you have DateOnly, what is the result there? And the list goes on.

I love the idea but two things come to my mind;

  • This is very opinionated and quickly gets tied to business rules and logic.
  • It can quickly grow complex it probably deserves its own package, Generator.Diffs

hayer avatar Feb 06 '24 23:02 hayer

Perhaps it is the wording, but my understanding is that this is a feature request to enumerate inequalities but not necessarily create diffs. I think that would be a reasonable feature to have, although I totally agree diffs are out of scope for this library.

diegofrata avatar Feb 07 '24 09:02 diegofrata

Yes inequality is sufficient!

Simonl9l avatar Feb 07 '24 15:02 Simonl9l