rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

Using `extra_protoc_args = ["--csharp_opt=internal_access"],` does not apply to generated services #281

Open saiimons opened 12 months ago

saiimons commented 12 months ago

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

aaliddell commented 11 months ago

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

saiimons commented 11 months ago

@aaliddell do you have an example of what does options could be?

Where can I find the docs about the C# grpc plugin?

aaliddell commented 11 months ago

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"],
}
saiimons commented 11 months ago

@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

github-actions[bot] commented 9 months ago

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.