Skip to content
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#: CustomOptions broken and deprecated without working alternatives #7043

Closed
ptr1120 opened this issue Dec 21, 2019 · 4 comments
Closed

C#: CustomOptions broken and deprecated without working alternatives #7043

ptr1120 opened this issue Dec 21, 2019 · 4 comments

Comments

@ptr1120
Copy link

ptr1120 commented Dec 21, 2019

What version of protobuf and what language are you using?
Version: v3.11.2
Language: C#

What operating system (Linux, Windows, ...) and version?
Win

What runtime / compiler are you using (e.g., python version or gcc version)
Generated C# classes from proto files using Grpc.Tools v2.26.0

What did you do?

ServiceName.proto

syntax = "proto3";
import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
    string service_name = 50001; 
}

SumRequestDto.proto

syntax = "proto3";
import "ServiceName.proto";

message SumRequestDto {
   option (service_name) = "Producer";
}

Program.cs

nternal class Program
    {
        private static void Main(string[] args)
        {
            SumRequestDto.Descriptor.CustomOptions.TryGetString(50001, out var messageName);
        }
    }

Until Google.Protobuf 3.8.0 everything worked fine with the above code.

I also tried the suggestion to use SumRequestDtoV1Reflection.Descriptor.GetOption() which requires a Extension<FileOptions, T> extension argument.

My Questions:

  • How can I generate these required Extensions in order the get my custom option value again?
  • Will there ever be a working version with custom options?

What did you expect to see
The variable messageName assigned to "Producer".

What did you see instead?
The variable messageName assigned to null.

@ObsidianMinor
Copy link
Contributor

ObsidianMinor commented Dec 21, 2019

Options currently:

@zeinali0
Copy link

zeinali0 commented Jan 25, 2020

I have same issue too.
And the problem is if we downgrade to 3.8.0 then we should downgrade Grpc.AspNetCore to 0.1.22-pre3 which would broke many things

@jtattermusch
Copy link
Contributor

@ObsidianMinor Grpc.Tools 2.28.x are already using protobuf 3.11. Does that mean the problem is solved now?

@ObsidianMinor
Copy link
Contributor

Should be solved, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants