-
Notifications
You must be signed in to change notification settings - Fork 71
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
normalization: add normalization of the options #848
normalization: add normalization of the options #848
Conversation
1. string 2. boolean 3. number 4. enum 5. map 6. list 7. option Here I've added an example for each one of them: 1. STRING: ``` option example_option = "hello world"; ``` 2. BOOLEAN: ``` option example_option = true; ``` 3. NUMBER: ``` option example_option = 42; ``` 4. ENUM: ``` enum ExampleEnum { OPTION_ONE = 1; OPTION_TWO = 2; } option example_option = OPTION_ONE; ``` 5. MAP: ``` message ExampleMessage { map<string, int32> example_map = 1; } option (map_option) = { key: "key1" value: 42 }; ``` 6. LIST: ``` message ExampleMessage { repeated string example_list = 1; } option (list_option) = [ "item1", "item2", "item3" ]; ``` 7. OPTION: ``` option (custom_option) = { string_option: "hello world", enum_option: OPTION_ONE, boolean_option: true }; ``` The goal of this pr its to start the process of normalization of the schemas initially just for the options in the protobuf types. # About this change - What it does It changes how the protobuf schema gets normalized before being saved # Why this way Seems that sorting alphabetically the options its a good way to provide an invariant over the order of the options. For the reviewers: I'm not completely familiar with protobuf nor the normalizations, please read each line of documentation (of the code and of the pr) and if anything doesn't sound right or you found something that seems wrong please discuss about it! I've added an example for each type of option just to make sure we are not loosing any important corner case. To me sounds reasonable to order those in any case. Additional normalizations could be added in another pr
eda6cae
to
478feb5
Compare
Support for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options are allowed on message and field level, I'd add the support for these also.
7557a8e
to
57372e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready to be reviewed again :)
# this would be a good case for using a property based test with a well-formed message generator | ||
# (hypothesis could work if the objects representing the language | ||
# do always correspond to a valid proto schema, that for a correct parser should always be true) | ||
# we should create a set of random valid DSLs and check that the normalization is giving back a sorted options list | ||
# | ||
# nb: we could use the protoc compiler as an oracle to check that the files are always valid protobuf schemas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
335fc9b
to
c56edd1
Compare
c56edd1
to
0b2d929
Compare
313fd6d
to
aa907ce
Compare
aa907ce
to
dde1f84
Compare
ea6e82f
da6bc5e
to
7293fc7
Compare
The options could be of different types:
Here I've added an example for each one of them:
The goal of this pr its to start the process of normalization of the schemas initially just for the options in the protobuf types.
About this change - What it does
It changes how the protobuf schema gets normalized before being saved
Why this way
Seems that sorting alphabetically the options its a good way to provide an invariant over the order of the options.
For the reviewers: I'm not completely familiar with protobuf nor the normalizations, please read each line of documentation (of the code and of the pr) and if anything doesn't sound right or you found something that seems wrong please discuss about it!
I've added an example for each type of option just to make sure we are not loosing any important corner case. To me sounds reasonable to order those in any case. Additional normalizations could be added in another pr