Open reponemec opened 2 years ago
Hi. Thanks a lot for so many improvements!!! I definitely like some of them. It's difficult to review so many changes in one pull request.
I know it's generally not a good idea to have multiple responsibilities in one PR. On the other hand, the main strength of the new features lies in the use of the comparison context and the difference tree. I needed to test these things against each other, so I'm sending the PR as is. But don't be afraid of many commits. Many of these are only typo commits, code comments commits and just technical commits, as I've often bounced between multiple machines with their own repositories over time. I believe that the code is sufficiently documented and can serve as an inspiration for merging it.
Let me know if you need further assistance in this.
I'm about to go on vacation so I'll have a closer look when I'll be back. Having features separated gives a flexibility to revert specific feature if needed and understand how feature was implemented looking at the change with only one specific feature. Would you mind if I manually create separate commits based on this pull request?
@reponemec This looks like a really useful PR that you put a lot of work into. Disappointing that nothing has happened with it :/
I'd be more then happy to merge some parts of this PR and release new version if PR will be separated into parts.
Oh yes, I see, that's a lot of commits and not easy to untangle :)
Please review my ideas for improving the library. All new features are unit tested and passed as well as all existing tests. New features brings no breaking changes, the original behavior of the library has been preserved by default. Existing "overrides" still take precedence over new features.
Comparison context and the difference tree
With the comparison context, you can configure each part of the comparison process separately. For example, you can compare one list by the index, while another by the key, one by the default key, and other by the key you provide. For one property, you can only compare lists of equal size, while for the other, unequal. Even the same property can be configured differently depending on its current context.
Using new CalculateDifferenceTree extension method, you get the tree of differences instead of a flat list. You can traverse the difference tree and examine differences at particular members.
All that is needed is to implement the IDifferenceTreeBuilder interface in a similar way as it was already implemented into all built-in comparers. Implementation into new or existing third-party comparers is easy and optional.
Calculates a difference tree
Difference improvements
Translates difference members
Includes raw values
List comparison improvements
Compares unequal lists
Compares lists by key
Note that MemberPath contains key, not an index, by default.
Supports null elements
Compares lists of objects by key
By default, no custom comparer is needed.
Formats element key
Compares lists by key but displays the index
Formats null element identifier
Compares first list by the key but second list by the index
Compares first list by the default key but second list by the custom key
Compares first list by the default key but second list by the custom key, formats custom key
Compares lists by complex key