Comments (2)
also note you don't have to use expressions - you could also just pass the path as follows:
var diff = obj1.Diff(obj2, ComparisonOptions.All | ComparisonOptions.IncludeList, ".Author.Address.City", ".Author.Address.Country");
from anydiff.
@SubasishMohapatra what should have been a simple use case turned out to be a bug! I've fixed this in version 1.0.73 - it turned out I had missed a use case in the tests for include/exclude expressions that have a direct path.
Here's an example that should be working now. The following will compare 2 different objects, but only compare City and Country because we specified that the expressions passed are property includes using ComparisonOptions.IncludeList
(by default it treats expressions as excludes, same as option ComparisonOptions.ExcludeList
)
var obj1 = new Cool {
Author = new Author {
FirstName = "John",
LastName = "Smith",
Address = new Address {
City = "Los Angeles",
Country = "USA"
}
}
};
var obj1 = new Cool {
Author = new Author {
FirstName = "Jane",
LastName = "Doe",
Address = new Address {
City = "Beijing",
Country = "China"
}
}
};
var diff = obj1.Diff(obj2, ComparisonOptions.All | ComparisonOptions.IncludeList, x => x.Author.Address.City, x => x.Author.Address.Country);
Assert.AreEqual(2, diff.Count); // only City and Country are different
from anydiff.
Related Issues (20)
- System.Reflection.TargetParameterCountException HOT 4
- Comparing objects of different types not working
- Cannot use AnyDiff within strong-named project. HOT 3
- Path is missing the array index HOT 3
- System.NotSupportedException thrown for AllowCollectionsToBeOutOfOrder flag
- Bug where AnyDiff recurses properties of a collection
- Add Ability to Diff Against NULL?
- Infinite loop when object contains a reference to Net Type. HOT 1
- How to speed up comparisons? HOT 3
- License HOT 3
- Feature Request - Add a new method that returns true, at the first encounter of difference HOT 1
- Can't serialize Difference because it does not have a parameterless constructor
- PR #26 introduced exclude bug HOT 2
- Reversing left and right objects in call to `Diff` changes the `diff.PropertyType` returned (but not `Property`) HOT 1
- Specified method is not supported HOT 3
- Possiblity to avoid diff of Enumerable null vs empty HOT 2
- Add a new attribute to avoid diff HOT 2
- Weird Output (Private fields?) HOT 2
- exception handling in GetDifferences HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anydiff.