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

Custom Options C#, Error 'FieldOptions' is inaccessible due to its protection level #6510

Closed
towny-trp opened this issue Aug 14, 2019 · 2 comments
Assignees
Labels

Comments

@towny-trp
Copy link

Version: 3.9.1
Language: C#
Linux & Windows
Protoc: Grpc.Protobuf.Tools.3.9.1

What did you do?
Steps to reproduce the behavior:

  1. Create a simple custom option proto in TestAnnotations.proto:
extend google.protobuf.FieldOptions {
  string test_field_opt1 = 5640936;
}
  1. Generate the c# code and compile via Grpc.Protobuf.Tools.3.9.1

  2. Code generated in invalid as it generates extension methods in the descriptor that access the FieldOptions, which it can't as FieldOptions is internal so you get the following error trying to compile:

Error	CS0122	'FieldOptions' is inaccessible due to its protection level
  1. Including the descriptor.proto in the build gets round the compilation issue (as it's then in the same assembly) - however if you do that you get another error trying to access the descriptor:
Message: System.TypeInitializationException : The type initializer for 'TestAnnotationsReflection' threw an exception.
---- System.ArgumentException : An item with the same key has already been added. Key: Google.Protobuf.ObjectIntPair`1[System.Type]

Anything else we should know about your project / environment
Using the Grpc.Tools 1.22.0 protoc compiler gets round this particular problem, but then you get hit by this issue 6509

@ObsidianMinor
Copy link
Contributor

ObsidianMinor commented Aug 14, 2019

Looks like the extension generation code made it into master. I'll make a PR today that removes it for a minor release.

@jtattermusch
Copy link
Contributor

The patched nuget is now available: https://www.nuget.org/packages/Google.Protobuf/3.10.1
Can you please test and report back if it solves the issue.

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

No branches or pull requests

5 participants