ValeraT1982 / ObjectsComparer

C# Framework provides mechanism to compare complex objects, allows to override comparison rules for specific properties and types.
MIT License
354 stars 87 forks source link

ExpandoObject with collections #2

Closed Thowk closed 6 years ago

Thowk commented 6 years ago

It seems to be a problem when comparing ExpandoObject containing collections.

I try to compare such jsons:

{ "Transaction": [ { "Name": "abc", "No": 101 } ] } { "Transaction": [ { "Name": "abc", "No": 102 } ] }

This is how my configuration looks like:

var comparer = new Comparer(new ComparisonSettings { RecursiveComparison = true });

dynamic responseJson = JsonConvert.DeserializeObject<ExpandoObject>(
    File.ReadAllText("result1.json"));

dynamic expectedJson = JsonConvert.DeserializeObject<ExpandoObject>(
    File.ReadAllText("result2.json"));

var isEqual = comparer.Compare(responseJson, expectedJson, out IEnumerable<Difference> diff);

Compare returns 'true'. (JsonConvert.DeserializeObject comes from Newtonsoft.Json)

Do you know how to solve that problem (is it a bug, or not yet implemented functionality)?

GregFinzer commented 6 years ago

Is this for .net core?

Thowk commented 6 years ago

Yes, but I guess the same is on i.e net461


From: Greg Finzer notifications@github.com Sent: Thursday, August 9, 2018 5:38:01 PM To: ValeraT1982/ObjectsComparer Cc: Thowk; Author Subject: Re: [ValeraT1982/ObjectsComparer] ExpandoObject with collections (#2)

Is this for .net core?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ValeraT1982/ObjectsComparer/issues/2#issuecomment-411801455, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARtemgASj9OofZ6EWVNOj5G1tTst9dGdks5uPFdZgaJpZM4V1rIv.

ValeraT1982 commented 6 years ago

Sorry for later answer. Every time I go to vacation somebody has an issue :) It doesn't work because the type of "Transaction" property is "System.Collections.Generic.List", so Comparer compares every element as an object (object doesn't have properties No and Name). Fix for this issue is committed now and probably will be in the next version (I need to think if it affects any other cases) in September.

@Thowk, you can download solution and build it manually to have this issue fixed or wait for the next version to be released.

ValeraT1982 commented 6 years ago

Resolved in 1.2