Protobuf2和Protobuf3自动生成代码方法

来源:互联网 发布:淘宝投诉编号在哪里看 编辑:程序博客网 时间:2024/06/05 18:02

Protobuf2

//required 不可以增加或删除的字段,必须初始化//optional 可选字段,可删除,可以不初始化//repeated 可重复字段,对应到C#文件里,生成的是Listmessage SearchResponse {  repeated Result result = 1;}message Result {  required string url = 1;  optional string title = 2;  repeated string snippets = 3;}


protobuf3

//optional required 要去掉//repeated 可重复字段,对应到C#文件里,生成的是Listsyntax = "proto3";package MyNet;message SearchResponse {  repeated Result result = 1;}message Result {  string url = 1;  string title = 2;  repeated string snippets = 3;}