1

From sample.proto

package Busy.Proto;
option optimize_for = SPEED;

message BusyRequest { required string message = 1;}
message BusyResponse {required string message = 1;} 
service BusyService {rpc Send (BusyRequest) returns (BusyResponse);}

generating .cs file, via following command, in package manager console

ProtoGen.exe sample.proto -output_directory="C:\SomeDir"

Resulting sample.cs file

 // Generated by ProtoGen, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589.  DO NOT EDIT!
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code

 using pb = global::Google.ProtocolBuffers;

 ...

  #region Services
  /*
  * Service generation is now disabled by default, use the following option to enable:
  * option (google.protobuf.csharp_file_options).service_generator_type = GENERIC;
  */
 #endregion

 ...

Tried

  • run ProtoGen.exe sample.proto -output_directory="C:\SomeDir" option (google.protobuf.csharp_file_options).service_generator_type = GENERIC; in Package manager Console. Ends with error

The term 'google.protobuf.csharp_file_options' is not recognized as the name ..

  • add option service_generator_type = GENERIC; in sample.proto. Ends with error

cannot resolve symbol

How enable Services generation ?

tchelidze
  • 8,050
  • 1
  • 29
  • 49

2 Answers2

1

With latest versions of protogen you can pass the services option in order to generate the services also: protogen --csharp_out=. --proto_path=. +services=true *.proto

I tested with protobuf-net.Protogen --version 3.0.0-alpha.122 and it seems not to work with 2.3.17 (last stable version as of today)

asidis
  • 1,374
  • 14
  • 24
0

Found answer on discussion here

ProtoGen.exe -service_generator_type=GENERIC sample.proto  -output_directory="someDIR"
tchelidze
  • 8,050
  • 1
  • 29
  • 49