feat: change all collections to ordered collections#2347
feat: change all collections to ordered collections#2347Michael-Wamae wants to merge 1 commit intomainfrom
Conversation
|
|
@Michael-Wamae Sorry for the randomization, @baywet and I have had some intense negotiations and have come to a compromise. Facts:
Compromise:
Sorry again for sending you down the wrong path. Hopefully, what we have learned here will reduce future maintenance work. /cc @baywet |
|
@darrelmiller Thanks for the update. Just to clarify, does this mean all collection properties will be reverted back to interfaces (including lists/sets), or does it only apply to dictionaries?
A comparer can only be used if the comparison obeys transitivity, which isn't always the case (example here). Although I'm not really concerned about such a limitation. If all collections are interfaces again, this enables us to preserve insertion order (which we need in some cases, such as the declaration order of API entity properties). Passing a custom comparer can't solve that. What's the plan here? |
|
Closing as superseded by #2363
Can you expand on this comment please? what impacts are you anticipating on this lib. |
Thanks for the clarification. I'll take another look after the new PR is merged.
The blog post I linked to explains it. For example, consider a list with content I don't have a concrete use case, but it's something to be aware of. Just assuming any sorting can be accomplished by taking a user-defined comparer simply isn't true. Using a comparer in .NET requires that a stable/complete/total ordering (I don't know the proper mathematical terminology) exists. |
|
The takeaway is that by offering collection interfaces instead of concrete types, users can define their own collections to honor such properties, and do so in an efficient way. |
|
Another case where this matters is culture-sensitive comparers. For example, in German, the letter |
|
Thank you for the additional information. For that German letter, do you typically expect it to appear after "B" when sorted alphabetically, or after "S" ? |
|
I have no idea. I'm not German. It's just an example to make my point. |


Fixes Allow for deterministic sorting while serializing collections #2329