proto files nested files?
See original GitHub issueI would like to split my proto file as follows:
syntax = "proto3";
option csharp_namespace = "GrpcService2";
package greet;
import "pkg1/greet.proto";
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (greet_types.HelloRequest) returns (greet_types.HelloReply);
}
and
syntax = "proto3";
option csharp_namespace = "GrpcService2";
package greet_types;
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings.
message HelloReply {
string message = 1;
}
So in the file system it looks as follows
But when I build the project there is an error:
I have also prepared a repo with this issue (https://github.com/MihailsKuzmins/GrpcService2) Basically it is the standard project, but only greet.proto is split.
So, is it possible to accomplish what I want (split generation rpc and models). My goal: generate models in the base project; generate client / server in child projects.
If it is not possible I will simply change gRPC models with other models, but I would like to keep gRPC models (less duplication) Any help is much appreciated 🙏
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Splitting protocol buffer definitions into multiple .proto files
Show activity on this post. import "myproject/base.proto";. Docs: https://developers.google.com/protocol-buffers/docs/proto#importing.
Read more >Nested protobuf file folders and cmake flattening the ...
I've tried making each subfolder a library and then linking them together into one 'meta'-library, which fixes the first two problems, but then ......
Read more >Protobuf - Nested Class
Protobuf Nested Class - Here, we will see how to create a nested class. ... to use the protoc binary to create the...
Read more >Language Guide (proto 2) | Protocol Buffers Documentation
This guide describes how to use the protocol buffer language to structure your protocol buffer data, including .proto file syntax and how to...
Read more >gRPC: Import nested proto files - OSS Support
Greetings! I try to use gRPC client like this: const client = new grpc.Client(); client.load( [PROTO_PATH] // some global path ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chwarr, thank you for the example, I have applied it in my final solution. I think it helped me solve the problem
@JamesNK looks like I have managed to get it working by changing the file name to
greet_types.proto
. When files have the same names nothing worked on my PC even after clean-rebuild and after deleting bin and obj foldersafter several hours of brainstorming (cleaning, rebuilding, reopening my IDE) I have finally achieved what I wanted. Indeed after I split proto files Visual Studio started to complain about compiling, but restarting the IDE solved these errors
GrpcBase.csproj - proto files, generate base types
GrpcMediatr.csproj - generate MediatR implementations
GrpcService.csproj - gRPC server
And my protos
greet.proto
greet_types.proto
base_types.proto
@JamesNK, please carry on with the awesome gRPC stuff. I really appreciate what you are doing for the community
You might need to clean the solution and rebuild. I needed to do that when I tested your scenario out.