Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort key-value pairs alphabetically by key name when serializing dictionaries to XML #74

Open
relgit opened this issue Nov 16, 2022 · 2 comments · May be fixed by #75
Open

Sort key-value pairs alphabetically by key name when serializing dictionaries to XML #74

relgit opened this issue Nov 16, 2022 · 2 comments · May be fixed by #75

Comments

@relgit
Copy link

relgit commented Nov 16, 2022

I'd like to suggest that plist-cil will sort key-value pairs alphabetically when it serializes a dictionary to XML, in the same way that plutil writes processed plists on the Mac.

While this will have no effect whatsoever on the data when deserialized, it will help greatly in cases where files are compared or diffed with previous versions to detect changes.

Right now the package serializes the pairs in the order that the Dictionary class provides, which is undefined. This means that a file loaded and written-back right away multiple times can potentially be different from one write to the other.

I'm considering plist-cil for a project which will process the about 200 plist files on the ProfileManifests project on an ongoing basis, and it is crucial to me that file output will be consistent and reproducible.

I can make the changes myself, but I'd like to see if there is openness to the idea around here 🙂

@qmfrederik
Copy link
Contributor

I'm not really convinced this should be a feature of plist-cil. If it is, at the very least, it should be opt-in.

@claunia
Copy link
Owner

claunia commented Nov 25, 2022

I see the usefulness of what @relgit is asking, but @qmfrederik why exactly you think it shall be opt-in?

We can have it as an option in the serializer so we use a SortedDictionary

@relgit relgit linked a pull request Jan 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants