StevenGilligan/AutoCompare

Unable to .Ignore() readonly properties.

Opened this issue · 0 comments

This library is Amazing!!! I keep evangelizing it for years.

Unless I am doing something wrong, I can't seem to successfully ignore a read-only property.

We have a graph as follows:

CaseDto (primary object to compare)
It has a public property "Client" of class ClientDto.
ClientDto has a readonly property (below) titled "AddressParts", this property appears as a Difference even though the property is mentioned in .Ignore(client => client.AddressParts) in configuration of type ClientDto (other ignored properties are ignored perfectly):

public class ClientDto
{
..
public string[] AddressParts => AddressStringHelper.ConstructTwoLineAddressParts(
AccountLocation?.AddressLine1,
AccountLocation?.AddressLine2,
AccountLocation?.City,
AccountLocation?.StateProvince,
AccountLocation?.ZipCode
);
}

Example of the Difference instance (if serialized to JSON):

{
"$type": "AutoCompare.Difference, AutoCompare",
"Name": "Client.AddressParts",
"OldValue": {
"$type": "System.String[], mscorlib",
"$values": [ "Street address", "SÃO PAULO, BRAZIL N/A" ]
},
"NewValue": {
"$type": "System.String[], mscorlib",
"$values": [ "Street address", "SÃO PAULO, BRAZIL N/A" ]
}
}