0

I have a solution laid out like this:

Project layout

As you can see, I've successfully linked service.proto into my OrchestrationServer project by adding this to my .csproj file:

<Protobuf Include="..\RequestHandler\Protos\service.proto" GrpcServices="None" ProtoRoot="..\RequestHandler\Protos\"/>

My question now is, how can I actually import this into my orchestrator.proto file? I've tried all sorts of paths without any luck. Currently, the two .proto files look like this

orchestrator.proto:

syntax = "proto3";

option csharp_namespace = "OrchestratorService";

package test;

import "service.proto";

service Orchestrator
{
  rpc EnqueueRequest(G_NewRequest) returns (G_NewResponse) { }
}

message G_NewRequest{
  string originId = 1;
  oneof request_type{
    G_RequestType1 request1 = 2;
    G_RequestType2 request2 = 3;
  }
}

message G_NewResponse{
  string response = 1;
}

service.proto:

syntax = "proto3";

option csharp_namespace = "RequestHandlerService";

package test;

service Handler
{
  rpc AddItem1(G_RequestType1) returns (G_NewResponse) { }
  rpc AddItem2(G_RequestType2) returns (G_NewResponse) { }
}

message G_RequestType1{
  string request = 1;
}

message G_RequestType2{
  string request = 1;
}

message G_NewResponse{
  string originId = 1;
  string response = 2;
}

Currently, errors are being thrown in orchestrator.proto for the referenced types from service.proto. Any help would be much appreciated. Additionally, if someone could lay out the extra steps that would be needed if the proto files declared different packages, that would be awesome too.

Matthew Heimlich
  • 343
  • 2
  • 13
  • Proto files are processed by an external tool; honestly, they should probably be side by side for simplicity here. Cross-project isn't going to be easy to set up. – Marc Gravell Apr 06 '21 at 17:20
  • @MarcGravell https://stackoverflow.com/questions/63470834/importing-proto-files-from-different-directories Others seems to have sorted it out. Not sure why the same isn't working in my case. – Matthew Heimlich Apr 06 '21 at 18:04

0 Answers0