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

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

Open
saiimons opened this issue Sep 1, 2023 · 5 comments

Comments

@saiimons
Copy link

saiimons commented Sep 1, 2023

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

@saiimons saiimons added the bug Something isn't working label Sep 1, 2023
@aaliddell
Copy link
Member

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 aaliddell added more-info-needed Further information is requested and removed bug Something isn't working labels Sep 7, 2023
@saiimons
Copy link
Author

saiimons commented Sep 7, 2023

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

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

@aaliddell
Copy link
Member

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
Copy link
Author

saiimons commented Sep 8, 2023

@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 github-actions bot added the stale label Nov 7, 2023
Copy link

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.

@aaliddell aaliddell reopened this Nov 13, 2023
@aaliddell aaliddell removed more-info-needed Further information is requested stale labels Nov 13, 2023
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

2 participants