-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comparison context, difference tree, list and another improvements #47
base: master
Are you sure you want to change the base?
Conversation
Extend CalculateDifferences operation with current comparision context.
Add ComparisionContext, IContextableComparer, IComparableExtensions. Extend CalculateDifferences operation with current comparision context.
…Comparer<T>, Comparer<T>.
Edit typeof(IComparisionContext) > typeof(IComparisionContext). Implement IContextableComparer, IContextableComparer<T> into AbstractEnumerablesComparer, EnumerablesComparer, EnumerablesComparer<T>, GenericEnumerablesComparer, HashSetsComparer, MultidimensionalArraysComparer. Edit typo ...comparision > ...comparison. Rename files ComparisionContext.cs > ComparisonContext.cs, IComparisionContext.cs > IComparisionContext.cs.
…onemec/ObjectsComparer into feat-list-custom-comparision
….Merge branch 'feat-list-custom-comparision' of https://github.com/reponemec/ObjectsComparer into feat-list-custom-comparision
…onemec/ObjectsComparer into feat-list-custom-comparision
Respect value1 and value2 positions in Difference instance. Add missed element in first/second object difference type.
…ntAndInequalityProperty.
…e_Order. Corrent string.empty at value1.
Raw values are optional.
…t method. Add ComparisonSettings.ConfigureDifference operation.
…jectsComprer.BuildDifferenceTree.
…ToDifference. Add InsertPathFactoryArgs.
Edit comments.
…s_Inequality tes method.
Hi. Thanks a lot for so many improvements!!! I definitely like some of them.
|
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.
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