Available on NuGet as well: https://www.nuget.org/packages/StructureComparer
###Description
A .NET library that it allows for comparison of primitive, value and enum types. It can be used to ensure the equality between entities.
###Example Usage###
Use StructureComparer static class and the Compare method to do comparisons.
StructureComparer.Compare
var customer = new Customer();
var customerDto = new CustomerDTO();
var result = StructureComparer.Compare(typeof(customer), typeof(customerDto));
var result = StructureComparer.Compare<Customer, CustomerDTO>();
The StructureComparisonResult class contains the result of comparison between entry types.
- AreEqual ( compared objects are equal? )
- DifferencesString ( result with the differences found ) - Example:
Failed to validate structures. Type 1: 'Int32', Type 2: 'Int16'. Property name: 'Id'
Failed to validate structures. Type 1: 'FakeEnum', Type 2: 'FakeEnumDifferentNames'. Property name: 'Enum'
Failed to validate structures. Type 1: 'FakeEnum', Type 2: 'FakeEnumDifferentNames'. Reason: divergent enum names. Property name: 'Enum' from 'FakeClass3' from 'FakeClass2'
Failed to validate structures. Type 1: 'FakeClass1', Type 2: 'FakeClass1'. Reason: property name 'FullName' was not found in type 'FakeClass1'