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

Config: Add comments to json config #3086

Merged
merged 5 commits into from
Jan 16, 2024
Merged

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jan 12, 2024

Description

This pr uses XML to replace the Json format to config neo node. The reason for this is Json format lacks the ability to add comments, as a result our json config can not tell users what a field is used for and what possible values can be used to set the node.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Directly run the node would work.

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration file doesn't need comments, it must be documented in somewhere else, in any case, we could accept both types

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 12, 2024

The configuration file doesn't need comments, it must be documented in somewhere else, in any case, we could accept both types

What make you think configuration does not need comments...... All the config file that i see in linux system and other systems contain comments.

Configuration files are exactly the place that needs comments.

@roman-khimov
Copy link
Contributor

XML is great. Except when it's used for human-editable configuration. I'd suggest YAML (see https://github.com/nspcc-dev/neofs-node/blob/master/config/example/node.yaml for inspiration), but you can't just throw away old configs, people won't be happy. Keep JSON, add something else.

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jan 12, 2024

You can add comments in json, What you talking about? Checkout https://github.com/cschuchardt88/neo-modules/blob/RestServer/src/RestServer/config.json

@superboyiii @vncoelho can verify this.

@vncoelho
Copy link
Member

@igormcoelho

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 13, 2024

@shargon Now revert everything back to json. Only keep the necessary comments that i want.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 13, 2024

XML is great. Except when it's used for human-editable configuration. I'd suggest YAML (see https://github.com/nspcc-dev/neofs-node/blob/master/config/example/node.yaml for inspiration), but you can't just throw away old configs, people won't be happy. Keep JSON, add something else.

I tried to switch to yml, but i think C# does not support yml very well. So just switch back to json.

@Jim8y Jim8y changed the title Config: use xml to replace json Config: Add comments to json config Jan 13, 2024
@shargon
Copy link
Member

shargon commented Jan 13, 2024

I think that comments in json are not in the standard, I need to check, it works with our reader at least

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jan 13, 2024

@shargon

I think that comments in json are not in the standard, I need to check, it works with our reader at least

There is nothing in the standard that says you can't have them. You can choose to support or not as in json parsers. Everything supports them now a days. Yes Microsoft, NewtonSoft.Json and Most tools like PostMan do support it.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 13, 2024

I think that comments in json are not in the standard, I need to check, it works with our reader at least

With who? reader? Do we still have any reader left?

@igormcoelho
Copy link
Contributor

There's a standard to JSON with comments, typically with extension .jsonc ... some IDEs recognize .json as .jsonc, but strictly speaking, it's better to support JSON with Comments (official implementation from Microsoft: https://github.com/Microsoft/node-jsonc-parser)

@igormcoelho
Copy link
Contributor

igormcoelho commented Jan 15, 2024

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 15, 2024

Another modern and excelent option for configuration is TOML: https://toml.io/en/ Three proposed C# implementations at wiki: https://github.com/toml-lang/toml/wiki

We dont need to worry about it, it works already.

@shargon shargon merged commit a7db45c into neo-project:master Jan 16, 2024
1 of 2 checks passed
@Jim8y Jim8y deleted the xml-config branch January 17, 2024 02:58
Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After command line PR we can create a simplified config with an example of command to call it

@roman-khimov roman-khimov added this to the v3.7.0 milestone Feb 27, 2024
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 this pull request may close these issues.

6 participants