feat(rust): name generated service types as prost-build does - #233
Merged
Merged
Conversation
protoc-gen-starpc-rust now resolves request and response types the way prost-build 0.14 resolves them, so a service file refers to the items that protoc-gen-prost wrote for the same schemas. Type paths follow the package module tree, nested messages and renamed identifiers included. The plugin parses extern_path and compile_well_known_types, applies exact mappings before the longest package prefix, installs the default google.protobuf mappings, rejects duplicate paths and rejects any other option. Service, method, stream trait and module names use ports of Prost's identifier sanitizing and heck's snake and upper camel case, kept with their licenses beside the code. Constructors use the field shorthand that Clippy requires. Tests cover the naming vectors, local, nested, cross-package and extern resolution, option parsing, two service files in one package and the constructor form. Signed-off-by: Christian Stewart <christian@aperture.us>
This file contains hidden or 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
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.
protoc-gen-starpc-rust now resolves request and response types the way prost-build 0.14 does, so generated service files refer to the items protoc-gen-prost writes for the same schemas, including packages that Prost nests, renames or merges across directories. The plugin parses extern_path and compile_well_known_types, applies exact mappings before the longest package prefix, installs the default google.protobuf mappings and rejects duplicate paths and unknown options.
Service, method, stream trait and module names go through ports of Prost's identifier sanitizing and heck's case conversion. Their Apache-2.0 and MIT license texts sit beside the code. The generated constructors use the field shorthand that Clippy requires, which removes redundant_field_names errors from every generated service file.
Tests beside the code cover naming vectors, local, nested, cross-package and extern resolution, option parsing, two service files in one package and the constructor form. The plugin passes go vet and its Go tests. A project fixture and a 453-test consumer workspace generated, compiled, linted with warnings denied and passed their tests against the plugin built from this change.