-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
C# protoc plugin: deprecated option in proto definitions should add Obsolete attribute to generated c# code #28597
Comments
Since the issue description mentions deprecated option for Enum values, see also protocolbuffers/protobuf#10513 |
For info: I've looked at the different places that the
@jskeet Can you think of any downside or gotchas if we add |
Not sure what the file level would look like - on the reflection class, maybe? Other than that, as you say I think it's only a matter of adding it to service and method, then updating the version of protoc in the gRPC github repo. |
FYI: the support for deprecating enums and enum values is not yet released - it is in Protocol Buffers v22.0-rc1. The gRPC repo currently has 21.12 as the protocol buffers submodule. |
Note: Google.Protobuf 3.22.0 has now been released. Additionally, I'd like to bring attention to the current state of affairs when a request/response pair are deprecated:
Currently for Google Cloud libraries we have to work around that by inserting a suppression pragma at the start of the gRPC-generated code. Marking the methods and fields (in the gRPC generated code) as obsolete removes this warning - but it does lead to an interesting contradiction: if the RPC is not marked as deprecated, but the request and/or response messages are, should the message be marked as obsolete? (I think it's easiest to mark it as obsolete if any of the request/response/rpc is deprecated.) |
@jskeet Propagating the deprecated ( Do we want to marked then bind methods as deprecated too? Or just disable obsolete warnings for those methods? Or we could just disable obsolete warnings for all the generated code (like you are doing by inserting the pragma yourself)? Is there any advantage in not disabling obsolete warnings for all the generated code since the user will find out the deprecated methods and messages themselves in their own code? |
Personally I think this is the simplest approach. You could even do it unconditionally, whether there's anything obsolete or not - with the downside that it would introduce a change to generated code which is unnecessary for most users. |
… and methods in C# generated code (#32414) Apply Obsolete attribute to deprecated services and methods in C# generated code Fix for #28597 - Deprecated support for enums and enum values is already fixed by protocolbuffers/protobuf#10520 but this is not yet released. It is fixed in Protocol Buffers v22.0-rc1 but the gRPC repo currently has 21.12 as the protocol buffers submodule. - Deprecated support for messages and fields already exists in the protocol buffers compiler. The fix in this PR adds `Obsolete` attribute to classes and methods for deprecated services and methods within services. e.g. ``` service Greeter { option deprecated=true; // service level deprecated // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) { option deprecated=true; // method level deprecated } } ``` I couldn't find any protocol buffers plugin tests to update. Tested locally.
fixed by #32414 |
… and methods in C# generated code (grpc#32414) Apply Obsolete attribute to deprecated services and methods in C# generated code Fix for grpc#28597 - Deprecated support for enums and enum values is already fixed by protocolbuffers/protobuf#10520 but this is not yet released. It is fixed in Protocol Buffers v22.0-rc1 but the gRPC repo currently has 21.12 as the protocol buffers submodule. - Deprecated support for messages and fields already exists in the protocol buffers compiler. The fix in this PR adds `Obsolete` attribute to classes and methods for deprecated services and methods within services. e.g. ``` service Greeter { option deprecated=true; // service level deprecated // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) { option deprecated=true; // method level deprecated } } ``` I couldn't find any protocol buffers plugin tests to update. Tested locally.
… and methods in C# generated code (grpc#32414) Apply Obsolete attribute to deprecated services and methods in C# generated code Fix for grpc#28597 - Deprecated support for enums and enum values is already fixed by protocolbuffers/protobuf#10520 but this is not yet released. It is fixed in Protocol Buffers v22.0-rc1 but the gRPC repo currently has 21.12 as the protocol buffers submodule. - Deprecated support for messages and fields already exists in the protocol buffers compiler. The fix in this PR adds `Obsolete` attribute to classes and methods for deprecated services and methods within services. e.g. ``` service Greeter { option deprecated=true; // service level deprecated // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) { option deprecated=true; // method level deprecated } } ``` I couldn't find any protocol buffers plugin tests to update. Tested locally.
… and methods in C# generated code (#32414) Apply Obsolete attribute to deprecated services and methods in C# generated code Fix for #28597 - Deprecated support for enums and enum values is already fixed by protocolbuffers/protobuf#10520 but this is not yet released. It is fixed in Protocol Buffers v22.0-rc1 but the gRPC repo currently has 21.12 as the protocol buffers submodule. - Deprecated support for messages and fields already exists in the protocol buffers compiler. The fix in this PR adds `Obsolete` attribute to classes and methods for deprecated services and methods within services. e.g. ``` service Greeter { option deprecated=true; // service level deprecated // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) { option deprecated=true; // method level deprecated } } ``` I couldn't find any protocol buffers plugin tests to update. Tested locally.
Is your feature request related to a problem? Please describe.
Adding the
Obsolete
attribute to an rpc method that is overriden warns that the base method is non-obselete:Obsolete member 'SomeService.SomeMethod(SomeRequest, ServerCallContext)' overrides non-obsolete member 'SomeService.SomeServiceBase.SomeMethod(SomeRequest, ServerCallContext)' [SomeService]csharp(CS0809)
The proto definitions look like this:
This is ignored in the generated code.
It also does not work on the enum level:
No attribute is added:
It works on the message level:
Which adds the
Obsolete
attribute:Describe the solution you'd like
Add the Obsolete attribute on the generated code when the deprecated option is set in the proto definition.
Describe alternatives you've considered
ignore warnings and use additional documentation and communication.
The text was updated successfully, but these errors were encountered: