KellermanSoftware.Compare-NET-Objects
Cache for properties, fields, and methods to speed up reflection
Reflection Cache for property info
Reflection Cache for field info
Reflection Cache for methods
Static constructor
Clear the cache
Get a list of the fields within a type
Get the value of a property
Get a list of the properties in a type
Get a method by name
Get the cached methods for a type
Compare Parameters
The configuration settings
The type of the first object
The type of the second object
Details about the comparison
A reference to the parent object1
A reference to the parent object2
The first object to be compared
The second object to be compared
The breadcrumb in the tree
Implements methods to support the comparison of objects for equality, in a customizable fashion.
Implements methods to support the comparison of objects for equality, in a customizable fashion.
The comparison object type.
Compare two objects of the same type to each other.
True if the objects are considered equivalent, according to the current CompareLogic.
Retrieves the hash of the specified object.
The object to retrieve a hash for.
Defines the configuration and logic by which Equals comparisons will be performed.
Gets or sets a value indicating whether the base object hashes should be used.
False by default to allow CompareLogic to evaluate equivalence of otherwise instance-sensitive hashing objects.
NOTE: Any object which doesn't override GetHashCode will behave this way, so this property should generally be left false.
Helper methods for files and directories
Get the current directory of the executing assembly
Ensure the passed string ends with a directory separator character unless the string is blank.
The string to append the backslash to.
String with a "/" on the end
Interface for mocking
Compare two objects of the same type to each other.
Check the Differences or DifferencesString Properties for the differences.
Default MaxDifferences is 1 for performance
True if they are equal
Reflection properties and fields are cached. By default this cache is cleared automatically after each compare.
The default configuration
Helper methods for processes
Execute an external program.
Path and filename of the executable.
Arguments to pass to the executable.
Window style for the process (hidden, minimized, maximized, etc).
Wait for the process to finish.
Exit Code
Class that allows comparison of two objects of the same type to each other. Supports classes, lists, arrays, dictionaries, child comparison and more.
CompareLogic compareLogic = new CompareLogic();
Person person1 = new Person();
person1.DateCreated = DateTime.Now;
person1.Name = "Greg";
Person person2 = new Person();
person2.Name = "John";
person2.DateCreated = person1.DateCreated;
ComparisonResult result = compareLogic.Compare(person1, person2);
if (!result.AreEqual)
Console.WriteLine(result.DifferencesString);
Set up defaults for the comparison
Pass in the configuration
Set up defaults for the comparison
If true, use settings from the app.config
Compare two objects of the same type to each other.
Check the Differences or DifferencesString Properties for the differences.
Default MaxDifferences is 1 for performance
True if they are equal
Reflection properties and fields are cached. By default this cache is cleared automatically after each compare.
The default configuration
Obsolete Use CompareLogic instead
Obsolete Use CompareLogic instead
Obsolete Use CompareLogic instead
Obsolete Use CompareLogic.Compare instead
Obsolete Use CompareLogic.ClearCache instead
Obsolete Use the ComparisonResult.ElapsedMilliseconds returned from CompareLogic.Compare
Obsolete Use CompareLogic.Config.ShowBreadcrumb instead
Obsolete Use CompareLogic.Config.MembersToIgnore for members or CompareLogic.Config.ClassTypesToIgnore instead
Obsolete Use CompareLogic.Config.MembersToInclude or CompareLogic.Config.ClassTypesToInclude instead
Obsolete Use CompareLogic.Config.ComparePrivateProperties instead
Obsolete Use CompareLogic.Config.ComparePrivateFields instead
Obsolete Use CompareLogic.Config.CompareStaticProperties instead
Obsolete Use CompareLogic.Config.CompareStaticFields instead
Obsolete Use CompareLogic.Config.CompareChildren instead
Obsolete Use CompareLogic.Config.CompareReadOnly instead
Obsolete Use CompareLogic.Config.CompareFields instead
Obsolete Use CompareLogic.Config.IgnoreCollectionOrder instead
Obsolete Use CompareLogic.Config.CompareProperties instead
Obsolete Use CompareLogic.Config.MaxDifferences instead
Obsolete Use the ComparisonResult.Differences returned from CompareLogic.Compare
Obsolete Use the ComparisonResult.DifferencesString returned from CompareLogic.Compare
Obsolete Use CompareLogic.Config.AutoClearCache instead
Obsolete Use CompareLogic.Config.Caching instead
Obsolete Use CompareLogic.Config.AttributesToIgnore instead
Obsolete Use CompareLogic.Config.IgnoreObjectTypes instead
Obsolete Use CompareLogic.Config.CustomComparers instead
Obsolete Use CompareLogic.Config.CustomComparers instead
Obsolete Use CompareLogic.Config.ExpectedName instead
Obsolete Use CompareLogic.Config.ActualName instead
Obsolete Use CompareLogic.Config.DifferenceCallback instead
Obsolete Use CompareLogic.Config.CollectionMatchingSpec instead
Details about the comparison
Set the configuration for the comparison
Keep track of parent objects in the object hiearchy
Add parent, handle references count
Remove parent, handle references count
Keep track of the depth of structs being compared. Used with ComparisonConfig.MaxStructDepth
Configuration
The amount of time in milliseconds it took for the comparison
The differences found during the compare
The differences found in a string suitable for a textbox
Returns true if the objects are equal
Returns true if the number of differences has reached the maximum
Configuration
Default Constructor
Reset the configuration to the default values
Ignore millisecond differences between DateTime values or DateTimeOffset values. The default is 0 (any time difference will be shown).
When comparing struct, the depth to compare for children. The default is 2
If true, unknown object types will be ignored instead of throwing an exception. The default is false.
If true, invalid indexers will be skipped. The default is false.
If a class implements an interface then only members of the interface will be compared. The default is all members are compared.
Show breadcrumb at each stage of the comparision. The default is false.
This is useful for debugging deep object graphs.
A list of class types to be ignored in the comparison. The default is to compare all class types.
Only these class types will be compared. The default is to compare all class types.
Ignore Data Table Names, Data Table Column Names, properties, or fields by name during the comparison. Case sensitive. The default is to compare all members.
MembersToIgnore.Add("CreditCardNumber")
Only compare elements by name for Data Table Names, Data Table Column Names, properties and fields. Case sensitive. The default is to compare all members.
MembersToInclude.Add("FirstName")
If true, private properties and fields will be compared. The default is false. Silverlight and WinRT restricts access to private variables.
If true, private fields will be compared. The default is false. Silverlight and WinRT restricts access to private variables.
If true, static properties will be compared. The default is true.
If true, static fields will be compared. The default is true.
If true, child objects will be compared. The default is true.
If false, and a list or array is compared list items will be compared but not their children.
If true, compare read only properties (only the getter is implemented). The default is true.
If true, compare fields of a class (see also CompareProperties). The default is true.
If true, compare each item within a collection to every item in the other. The default is false. WARNING: setting this to true significantly impacts performance.
If true, compare properties of a class (see also CompareFields). The default is true.
The maximum number of differences to detect. The default is 1 for performance reasons.
The maximum number of differences to detect when comparing byte arrays. The default is 1.
Reflection properties and fields are cached. By default this cache is cleared after each compare. Set to false to keep the cache for multiple compares.
By default properties and fields for types are cached for each compare. By default this cache is cleared after each compare.
A list of attributes to ignore a class, property or field
AttributesToIgnore.Add(typeof(XmlIgnoreAttribute));
If true, objects will be compared ignore their type diferences. The default is false.
In the differences string, this is the name for expected name. The default is: Expected
In the differences string, this is the name for the actual name. The default is: Actual
Callback invoked each time the comparer finds a difference. The default is no call back.
Sometimes one wants to match items between collections by some key first, and then
compare the matched objects. Without this, the comparer basically says there is no
match in collection B for any given item in collection A that doesn't Compare with a result of true.
The results of this aren't particularly useful for object graphs that are mostly the same, but not quite.
Enter CollectionMatchingSpec
The enumerable strings should be property (not field, for now, to keep it simple) names of the
Type when encountered that will be used for matching
You can use complex type properties, too, as part of the key to match. To match on all props/fields on
such a matching key, Don't set this property (default comparer behavior)
NOTE: types are looked up as exact. e.g. if foo is an entry in the dictionary and bar is a
sub-class of foo, upon encountering a bar type, the comparer will not find the entry of foo
A list of custom comparers that take priority over the built in comparers
If true, string.empty and null will be treated as equal. The default is false.
The precision to compare double values. The default is 0.
Detailed information about the difference
Item and property name only
The type and index of what is compared
Nicely formatted string
Name of Expected Object
Name of Actual Object
Returns the parent property name
The breadcrumb of the property leading up to the value
The child property name
Object1 Value as a string
Object2 Value as a string
The type of the first object
The type of the second object
A reference to the parent of object1
A reference to the parent of object2
Object1 as a reference
Object2 as a reference
Prefix to put on the beginning of the message
Logic for comparing lists that are out of order based on a key
Common functionality for all Comparers
Add a breadcrumb to an existing breadcrumb
Comparison configuration
The existing breadcrumb
The field or property name
The new breadcrumb
Add a breadcrumb to an existing breadcrumb
The comparison configuration
The existing breadcrumb
The property or field name
Extra information to output after the name
The index for an array, list, or row
The new breadcrumb
Add a breadcrumb to an existing breadcrumb
Comparison configuration
The existing breadcrumb
The field or property name
Extra information to append after the name
The index if it is an array, list, row etc.
The new breadcrumb
Add a difference for the current parameters
Add a difference to the result
The difference to add to the result
The comparison result
Convert an object to a nicely formatted string
Initializes a new instance of the class.
The root comparer.
Compares the enumerators and ignores the order
Abstract Base Duel File Report that has default Output
Define a dual file report like Beyond Compare, WinMerge etc.
Output the differences to two files
A list of differences
The path to write the expected results
The path to write the actual results
Launch the comparison application
The path to write the expected results
The path to write the actual results
Create two difference files and compare in WinMerge
A list of the differences
The path to write the expected results
The path to write the actual results
Launch application to compare two files
The path for the expected file results
The path for the actual file results
Report for showing differences to an end user
Defines a Single File Report
Output the differences to a file
A list of differences
The file path
Output the differences to a stream
A list of differences
Where to write to
Output the differences to a string
A list of differences
A string
Launch the application for showing the file
The file path
Initializes a new instance of the class.
Output the differences to a file
A list of differences
The file path
Output the differences to a stream
A list of differences
Where to write to
Output the differences to a string
A list of differences
A string
Launch the application for showing the file
The file path
The text in between the values. Defaults to: CHANGED TO ->
Output files and launch WinMerge
Launch the WinMerge
The path to write the expected results
The path to write the actual results
Find the path of the WinMerge executable
The path or null if not found
Output files and launch Beyond Compare
Launch the WinMerge
The path to write the expected results
The path to write the actual results
Find the path of the Beyond Compare executable
The path or null if not found
Create a CSV file of the differences and launch the default CSV handler (usually Excel)
Output the differences to a file
A list of differences
The file path
Output the differences to a stream
A list of differences
An output stream
Output the differences to a string
A list of differences
A string
Launch the WinMerge
The differences file
Escape special characters
The base comparer which contains all the type comparers
Compare two objects
A list of the type comparers
Factory to create a root comparer
Get the current root comparer
Methods for manipulating strings
Insert spaces into a string
OrderDetails = Order Details
10Net30 = 10 Net 30
FTPHost = FTP Host
Compare two byte arrays
Common functionality for all Type Comparers
Protected constructor that references the root comparer
If true the type comparer will handle the comparison for the type
The type of the first object
The type of the second object
Compare the two objects
A reference to the root comparer as newed up by the RootComparerFactory
Protected constructor that references the root comparer
The root comparer.
If true the type comparer will handle the comparison for the type
The type of the first object
The type of the second object
true if it is a byte array; otherwise, false.
Compare two byte array objects
Compare two objects of type class
Constructor for the class comparer
The root comparer instantiated by the RootComparerFactory
Returns true if the both objects are a class
The type of the first object
The type of the second object
Compare two classes
Compare all columns in a data row
Constructor that takes a root comparer
Returns true if this is a DataRow
The type of the first object
The type of the second object
Compare two data rows
Compare all tables and all rows in all tables
Constructor that takes a root comparer
Returns true if both objects are data sets
The type of the first object
The type of the second object
Compare two data sets
Compare all rows in a data table
Constructor that takes a root comparer
Returns true if both objects are of type DataTable
The type of the first object
The type of the second object
Compare two datatables
Compare DateTimeOffsets with the ability to ignore millisecond differences
Constructor that takes a root comparer
Returns true if both types are DateTimeOffset
Compare two DateTimeOffset
Compare Double values with the ability to specify the precision
Constructor that takes a root comparer
Returns true if both types are double
Compare two doubles
Compare dates with the option to ignore based on milliseconds
Constructor that takes a root comparer
Returns true if both types are DateTime
Compare two DateTime variables
Logic to compare two dictionaries
Constructor that takes a root comparer
Returns true if both types are dictionaries
The type of the first object
The type of the second object
Compare two dictionaries
Logic to compare to enum values
Constructor with a default root comparer
Returns true if both objects are of type enum
The type of the first object
The type of the second object
Compare two enums
Logic to compare two LINQ enumerators
Constructor that takes a root comparer
Returns true if either object is of type LINQ Enumerator
The type of the first object
The type of the second object
Compare two objects that implement LINQ Enumerator
Exclude types depending upon the configuration
Returns true if the property or field should be excluded
Check if the class type should be excluded based on the configuration
Check if any type has attributes that should be bypassed
Compare all the fields of a class or struct (Note this derrives from BaseComparer, not TypeComparer)
Constructor with a root comparer
Compare the fields of a class
Class FontDescriptorComparer.
Protected constructor that references the root comparer
The root comparer.
If true the type comparer will handle the comparison for the type
The type of the first object
The type of the second object
true if [is type match] [the specified type1]; otherwise, false.
Compare the two fonts
Logic to compare two hash sets
Constructor that takes a root comparer
Returns true if both objects are hash sets
The type of the first object
The type of the second object
Compare two hash sets
Compare objects that implement IList
Constructor that takes a root comparer
Returns true if both objects implement IList
The type of the first object
The type of the second object
Compare two objects that implement IList
Logic to compare an integer indexer (Note, inherits from BaseComparer, not TypeComparer)
Constructor that takes a root comparer
Compare an integer indexer
Logic to compare two IP End Points
Constructor that takes a root comparer
Returns true if both objects are an IP End Point
The type of the first object
The type of the second object
Compare two IP End Points
Logic to compare to pointers
Constructor that takes a root comparer
Returns true if both types are a pointer
The type of the first object
The type of the second object
Compare two pointers
Compare two properties (Note inherits from BaseComparer instead of TypeComparer
Constructor that takes a root comparer
Compare the properties of a class
Logic to compare two runtime types
Constructor that takes a root comparer
Returns true if both types are of type runtme type
Compare two runtime types
Compare primitive types (long, int, short, byte etc.) and DateTime, decimal, and Guid
Constructor that takes a root comparer
Returns true if the type is a simple type
The type of the first object
The type of the second object
Compare two simple types
Compare two strings
Constructor that takes a root comparer
Returns true if both objects are a string or if one is a string and one is a a null
The type of the first object
The type of the second object
Compare two strings
Compare two structs
Constructor that takes a root comparer
Returns true if both objects are of type struct
Compare two structs
Logic to compare two timespans
Constructor that takes a root comparer
Returns true if both objects are timespans
The type of the first object
The type of the second object
Compare two timespans
Compare two URIs
Constructor that takes a root comparer
Returns true if both types are a URI
The type of the first object
The type of the second object
Compare two URIs
Methods for detecting
Returns true if it is a byte array
Returns true if the type can have children
True if the type is an array
Returns true if it is a struct
Returns true if the type is a timespan
Return true if the type is a class
Return true if the type is an interface
Return true if the type is a URI
Return true if the type is a pointer
Return true if the type is an enum
Return true if the type is a dictionary
Return true if the type is a hashset
Return true if the type is a List
Return true if the type is an Enumerable
Return true if the type is a Double
Return true if the type is a DateTime
Return true if the type is a DateTimeOffset
Return true if the type is a string
Return true if the type is a primitive type, date, decimal, string, or GUID
Returns true if the Type is a Runtime type
Returns true if the type is an IPEndPoint
Returns true if the type is a dataset
Returns true if the type is a data table
Returns true if the type is a data row
Returns true if the type is a font
The type1.