CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
801 stars 112 forks source link

Add tests for random attribute order #109

Closed acecilia closed 5 years ago

acecilia commented 5 years ago

This is PR to showcase the issue https://github.com/MaxDesiatov/XMLCoder/issues/108. Build should fail due to the DynamicNodeEncodingTest.testEncode() test not passing.

The attributes order is random is because a Swift Dictionary is used to store them. A Dictionary is an unordered collection of keys and values.

In theory, that is fine, as the XML specification says that the order of the attributes is not important.

In practise, the result of this is that the encoding operation is not idempotent: despite using the same model, every time an encoding operation is performed, the resulting XML string has different attributes sorting. This is a major problem in several scenarios, but the most important is during tests.

acecilia commented 5 years ago

Feel free to close this PR when you do not need it anymore

MaxDesiatov commented 5 years ago

@acecilia thank you! Can I assume that this is included in #110?

acecilia commented 5 years ago

@MaxDesiatov Yes, this is included in https://github.com/MaxDesiatov/XMLCoder/pull/110