Replies: 2 comments 5 replies
-
You don't need that. Just use a type like EquatableArray |
Beta Was this translation helpful? Give feedback.
-
|
@Kralizek It's a deeper problem than it might seem at glance. You're right about EquatableArray solving a very specific problem but that's how you clearly indicate how you want your data to be compared. How far do you want compiler to go trying to generate an "optimal" equality behavior? Do you want to have special recognition of specific types? How many of those and how many combinations? Do you want record equality and default comparer equality to be different? e.g. What if you have an array of arbitrary objects? What if you need equality contract based on external data? All of these things are simply solved with a custom type which exposes equality contract you provide. It's a cheap price to pay compared to all of the quirks automatic "smart" equality generation might introduce. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I love records. Until I hate them.
In my project I use them mostly as DTO to serialize/deserialize responses from the backend.
This one specific record is mostly strings, bools and enums and equality comparison just worked fine.
Then we needed to add a property which was a string array and the comparison broke.
I know exactly where and why it broke and how to fix it.
It's just annoying that I go from 0 code to a massive overridden method because of one property.
I know the language team often try to work out scenarios like this one where one small change tips the scale massively.
So this post is just to hope the team sees this message and thinks there's something that can be done to avoid having to override the whole equality comparison process and just specify how the "offending" property should be handled.
I couldn't find similar discussion but the following are somehow related: #5767, #4845
Beta Was this translation helpful? Give feedback.
All reactions