Add class-retention @GrpcGenerated annotation to generated types
See original GitHub issueIs your feature request related to a problem?
Static analyzers (e.g. lint checks and proguard) would like to reliably detect that code has been generated by gRPC in order exclude it from some types of validation. Currently, gRPC-generated types are annotated with the @Generated
annotation, but this only has SOURCE
retention and is unavailable to these analyzers.
Describe the solution you’d like
Additionally add an @GrpcGenerated
annotation with CLASS
retention to generated types.
Describe alternatives you’ve considered
Currently we inspect generated code for anticipated naming schemes and structure (e.g. endsWith(“Grpc”) & contains X fields) in order to determine if it is grpc-generated. Obviously this is fragile and relies on implementation details that it shouldn’t.
Additional context
There is prior art for this kind of annotation in Dagger and AutoFactory
(coming soon).
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
GrpcGenerated (grpc-all 1.51.0 API)
Annotates that the class is gRPC-generated code to assist Java Annotation Processors. This annotation is used by the gRPC stub compiler to annotate...
Read more >I use gRPC to generate java code '@javax.annotation ...
you can add javax.annotation-api dependencies to you maven pom.xml to resolve the annotation.
Read more >Customizing gRPC Generated Code - ITNEXT
This code is generated by the protoc compiler from the .proto files. ... This will allow us to add helper/utility methods that have...
Read more >Java Generated Code | Protocol Buffers - Google Developers
The protocol buffer compiler will generate a Java enum type called Foo with the same set of values. If you are using proto3,...
Read more >Generated-code reference | Java - gRPC
gRPC Java generates code for three types of stubs: asynchronous, ... Typically the build system handles creation of the gRPC generated code.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dapengzhang0, note that RpcMethod has this in its documentation:
Then inspecting for
@RpcMethod
is less fragile than I thought.