Closed
Description
Version: 3.9.1
Language: C#
Linux & Windows
Protoc: Grpc.Protobuf.Tools.3.9.1
What did you do?
Steps to reproduce the behavior:
- Create a simple custom option proto in TestAnnotations.proto:
extend google.protobuf.FieldOptions {
string test_field_opt1 = 5640936;
}
-
Generate the c# code and compile via Grpc.Protobuf.Tools.3.9.1
-
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
- 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
Activity