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.
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. ADictionary
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.