rules_proto_grpc
rules_proto_grpc copied to clipboard
Using `extra_protoc_args = ["--csharp_opt=internal_access"],` does not apply to generated services
Issue Description
When using the option to make generated classes internal, the generated messages are internal, but the ServiceApiBase and ServiceApiClient are all public.
csharp_grpc_compile(
name = "service_csharp_protos",
extra_protoc_args = ["--csharp_opt=internal_access"],
protos = ["..."]
Generated code:
[grpc::BindServiceMethod(typeof(ServiceApi), "BindService")]
public abstract partial class ServiceBase
// All public methods
Log Output
No response
rules_proto_grpc Version
4.4.0
Bazel Version
6.3.2
OS
MacOS 13.5
Link to Demo Repo
No response
WORKSPACE Content
No response
BUILD Content
No response
Proto Content
No response
Any Other Content
No response
That arg as specified will only apply to the protobuf plugin for protoc, not the grpc plugin also. You need to specify per-plugin options for each of the protobuf and grpc C# plugins using the options attr instead of extra_protoc_args
@aaliddell do you have an example of what does options could be?
Where can I find the docs about the C# grpc plugin?
I don't know where the docs are for the C# grpc plugin, but assuming it takes the same option as the protobuf plugin, you should use an options arg like (not tested):
options = {
"@rules_proto_grpc//csharp:csharp_plugin": ["internal_access"],
"@rules_proto_grpc//csharp:grpc_csharp_plugin": ["internal_access"],
}
@aaliddell this works, thanks a lot!
I think it would be awesome to have these small details documented.
Also, on a totally different note, I put something up with the latest rules_dotnet to generate an assembly out of the protos.
https://github.com/saiimons/bazel-dotnet-test/blob/main/BUILD.bazel
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.