-
Notifications
You must be signed in to change notification settings - Fork 181
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
Add option to the protoc code generator to avoid generating deprecated code #3089
Add option to the protoc code generator to avoid generating deprecated code #3089
Conversation
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.
Token approval: this looks fine to me but please wait for a more experienced reviewer before merging.
How was it tested? I presume manually, but it would be good to document it in the PR description.
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Main.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
…ing-deprecated-calls
…est full scope of generation
New diff from test_service.proto: https://gist.github.com/mgodave/5772193156ca740ea90ca11bafb3da56 |
…oc/Main.java Co-authored-by: Idel Pivnitskiy <idel.pivnitskiy@apple.com>
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.
Really good progress! New generated code looks much better than without skipDeprecated
option.
Just a few adjustments for the final findings and we are ready to ship:
servicetalk-examples/grpc/protoc-options/src/main/proto/test_service.proto
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcRoutes.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcRoutes.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
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 work!
The generated code with skipDeprecated=true
looks good. I also checked diff for default behavior. Many things changed their order, which is ok. Couldn't spot anything suspicious, but would be great if someone can have another look at the diff @bryce-anderson. We need to make sure current users won't be affected.
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
…oc/Generator.java
The ordering is probably based on me trying to keep the blocks of |
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.
I also looked at a diff of the generated code and didn't see anything suspicious. That said, it's a lot of generated code. 😅
…d code (apple#3089) ### Motivation The generated ServiceTalk gRPC stubs make use of deprecated calls. This causes a problem when `-Werror` is used to build the code since it will automatically fail the build. We should allow users who have already migrated their code to prevent the protoc compiler from generating and using deprecated references. ### Modifications Add an option, `skipDeprecated`, as part of the protoc compiler configuration, to tell the generator to leave out deprecated references. Remove - initSerializationProvider, reason: ContentCodec is deprecated - isSupportedMessageCodingsEmpty, reason ContentCodec is deprecated - Deprecated ServiceFactory constructors - ServiceFactory::Builder references to ContentCodec - Generated client metadata and associated methods, reason: deprecated ### Result Users can generate gRPC stubs without deprecated code. ### Testing Manually tested: - Add new option to ServiceTalk/examples/grpc/protoc-options and use it to generate test_service.proto which covers all combinations of streaming (or not) services.
…d code (apple#3089) ### Motivation The generated ServiceTalk gRPC stubs make use of deprecated calls. This causes a problem when `-Werror` is used to build the code since it will automatically fail the build. We should allow users who have already migrated their code to prevent the protoc compiler from generating and using deprecated references. ### Modifications Add an option, `skipDeprecated`, as part of the protoc compiler configuration, to tell the generator to leave out deprecated references. Remove - initSerializationProvider, reason: ContentCodec is deprecated - isSupportedMessageCodingsEmpty, reason ContentCodec is deprecated - Deprecated ServiceFactory constructors - ServiceFactory::Builder references to ContentCodec - Generated client metadata and associated methods, reason: deprecated ### Result Users can generate gRPC stubs without deprecated code. ### Testing Manually tested: - Add new option to ServiceTalk/examples/grpc/protoc-options and use it to generate test_service.proto which covers all combinations of streaming (or not) services.
Motivation
The generated ServiceTalk gRPC stubs make use of deprecated calls. This causes a problem when
-Werror
is used to build the code since it will automatically fail the build. We should allow users who have already migrated their code to prevent the protoc compiler from generating and using deprecated references.Modifications
Add an option,
skipDeprecated
, as part of the protoc compiler configuration, to tell the generator to leave out deprecated references.Result
Example: Tester.java before/after (option enabled) https://gist.github.com/mgodave/5772193156ca740ea90ca11bafb3da56
Example: Tester.java before/after (option disabled) https://gist.github.com/mgodave/dcff4574f0b70cb39c3bd97a859565ac
Remove
Testing
Manually tested: