Open YarnSphere opened 3 months ago
Unfortunately this cannot work currently as list deserialization explicitly uses the AbstractCollectionSerializer to handle incremental reading of list elements. To avoid that the deserializer would need to buffer all list entries and only provide them at the end, as list.
I see, that is indeed unfortunate. Appreciate the prompt reply!
Description
Consider the following toy example:
Where
ShoppingCartSerializer
is a custom serializer, which serializesShoppingCart
as a list:The following test, which should pass, does not:
The first assert passes, i.e., encoding is correct. The second assert, however, fails with:
I.e., decoding drops all items of the collection but the last.
Notes
List
,Set
,Array
, etc.) for the shopping cart directly instead of a class with a delegated serializer results in the decoding working as expected.SetSerializer
or any other "built-in" collection serializer results in the same incorrect behaviour.deserialize
function is called once for each item of the collection, instead of only being called once for the whole collection.Reproduction
The code above showcasing the issue is available at: https://github.com/YarnSphere/xmlutil-custom-collection-serialization
Versions tested
0.86.3
with Kotlin1.9.24
0.90.0-RC2
with Kotiln2.0.0