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

Use the #[sorted] macro on more conda json types #125

Closed
2 tasks
wolfv opened this issue Mar 21, 2023 · 2 comments · Fixed by #180
Closed
2 tasks

Use the #[sorted] macro on more conda json types #125

wolfv opened this issue Mar 21, 2023 · 2 comments · Fixed by #180
Assignees
Labels
good first issue Good for newcomers

Comments

@wolfv
Copy link
Contributor

wolfv commented Mar 21, 2023

For reproducibility reasons we want to ensure that fields are serialized in a deterministic (alphabetical) order.

To achieve this, we have a macro in rattler_macros that ensures that all struct fields are sorted alphabetically.

We need to apply this to more structs, such as

  • IndexJson
  • AboutJson
  • possibly more
@travishathaway
Copy link
Contributor

@wolfv, could you assign this to me. I have already started working on it.

If I understand it correctly, that "sorted" macro is basically just a code linter, right? At first I thought it might sort the fields for you, but it looks like all it does is raise a compilation error if you haven't sorted these fields yourself.

@wolfv
Copy link
Contributor Author

wolfv commented Apr 25, 2023

Hi @travishathaway yes, exactly, it's a compile-time linter so to say :)

Unfortunately it doesn't work when renaming fields with the serde rename function so sometimes we have to take care "manually". I tried once to make it work but it was pretty hard.

It's also not strictly necessary that the fields are sorted, but I think it's good to encode the alphabetical ordering so that we know how to "reproducibly" create the JSON files in any language :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants