-
Notifications
You must be signed in to change notification settings - Fork 11.1k
C# protoc plugin: deprecated option in proto definitions should add Obsolete attribute to generated c# code #28597
Copy link
Copy link
Closed
Description
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:
service SomeService {
rpc SomeMethod (SomeRequest) returns (SomeReply) {
option deprecated = true;
}This is ignored in the generated code.
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
public virtual global::System.Threading.Tasks.Task<global::GrpcSomeService.SomeReply> SomeMethod(global::GrpcSomeService.SomeRequest request, grpc::ServerCallContext context)It also does not work on the enum level:
enum SomeEnum {
option deprecated = true;
A = 0 [deprecated = true];
}No attribute is added:
#region Enums
public enum SomeEnum {
[pbr::OriginalName("A")] A = 0,
}It works on the message level:
message SomeRequest {
option deprecated = true;
SomeEnum somefield = 1;
}Which adds the Obsolete attribute:
[global::System.ObsoleteAttribute]
public sealed partial class SomeRequest : pb::IMessage<SomeRequest>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.
Reactions are currently unavailable