-
Notifications
You must be signed in to change notification settings - Fork 466
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
Better handing of proto identifiers that start with underscores and numbers #947
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update test cases to have more failures and use the argument.
- Document what the input set it. - Handing leading underscores followed by a number which used to result in the generation of an invalid Swift identifier starting with a number. - Expand the testcases to cover the improved code and cover handling of repeated underscores (they just go away).
This is just a compile test. Tests/SwiftProtobufPluginLibraryTests/Test_NamingUtils.swift also covers this behavior but making a full compile test to be safe.
- Rename the UnicodeScalar helpers to to make it clear they only takes ASC. - Stop exporting the camelcase helpers from the plugin lib, make a new temporary api that will better supported in followup.
Document the inputs to toUpper|LowerCamelCase (splitIdentifier), and dea; with input that would have resulted in a leading number which isn't valid. This fixes the field name issues in apple#931 as well as the naming of the generated oneof enums.
This is just a compile test. Tests/SwiftProtobufPluginLibraryTests/Test_NamingUtils.swift also covers this behavior but making a full compile test to be safe.
For enum prefix stripping, some validation was happening after the stripping, move that into the stripper so it won't return a stripped value that isn't something that should be used to generate a swift name from. Add some basic test cases to ensure it is working as expected.
This is just a compile test. Tests/SwiftProtobufPluginLibraryTests/Test_NamingUtils.swift also covers this behavior but making a full compile test to be safe.
allevato
approved these changes
Feb 5, 2020
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.
Great improvements!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code changes and docs to better document what input some methods during generation have to deal with based on the restrictions protoc enforces when parsing proto files.
There are no changes to what was generated before (and compiled), but there is one case (extensions at the root of a file) that can still fail to generate. But, that was already failing to generate (trips a
precondition
), so there is no change in behavior. That will get looked at next, but does as a follow up PR to keep it more self contained.Fixes #931