You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var config = new SerializerConfig();
config.UseImmutableFormatters();
var s = new CerasSerializer(config);
var o = ImmutableDictionary<string, int>.Empty.WithComparers(StringComparer.OrdinalIgnoreCase);
var x = s.Serialize(o);
var y = s.Deserialize<ImmutableDictionary<string, int>>(x);
Console.WriteLine(o.KeyComparer.GetType());
Console.WriteLine(y.KeyComparer.GetType());
Actual output:
System.OrdinalIgnoreCaseComparer
System.Collections.Generic.GenericEqualityComparer`1[System.String]
Yep, none of the collection formatters persist the equality comparer.
I guess that's something that should be fixed for some of them.
I think the commonly known types like list, hash set, dictionary,... Should have their equality comparer saved and restored.
For all others, it is not possible I think.
We can not assume anything about some custom IList implementation.
For those troublesome cases a custom formatter can be written (which is extremely).
For immutable collections I'll count that as a bug as well. I've added it to my Todo list.
Until then, you can use a custom formatter. (let me know if anything is unclear about that 😄)
Test code:
Actual output:
System.OrdinalIgnoreCaseComparer
System.Collections.Generic.GenericEqualityComparer`1[System.String]
Expected output:
System.OrdinalIgnoreCaseComparer
System.OrdinalIgnoreCaseComparer
The text was updated successfully, but these errors were encountered: