hello C# users

it is 4:30 in the morning

and i just used reflection

the fact that it's 4:30 in the morning? fine

the fact that i just used reflection? fine

both together? decidedly not fine, apparently


needed to compare two objects to make sure they were the same after being serialized and deserialized

they didn't define Equals() or anything so i decided to compare all the properties directly

except some of the properties are lists of other classes that also don't have Equals() so i also have to use reflection to make sure all the properties match there

it was actually almost much worse, earlier i was using dynamic variables to try to determine what type a list had in it just from knowing it was a list and then comparing that way but i couldn't quite get it working so i just only check for the two list types i know there are


Oh shit. This would seriously tempt me to give up on the type system for this problem.

Use newtonsoft to cast both to jtoken (json) and use the built in jtoken.deepequals()

I'm sure a custom solution executes faster and more bullet proof, but sometimes you just cant even.

@polyphonic unfortunately this is a unit test for deserializing json so it would sort of defeat the point

Hmm, I'm not entirely sure why you couldn't use one deserializer to validate the results of another, but you know the requirements best.

And my way is a sketchy, lazy hack even in the best of times.

Anyway, sorry you had to write all that. I had similar deserialization issues with a polymorphic collection of classes last week that kept matching to the wrong types. Took a few tries to get right. No fun.

@polyphonic i mean it's the same deserializer, which is the problem :P

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!