在什么情况下可以protogen.exe
应用于每个属性只有一个 getter(而不是 setter)的.proto
文件生成类?C#
package MyLibrary.MyProto
import "MyExternalType.proto";
option optimize_for = SPEED;
message MyProto {
repeated MyExternalType MyProperty = 1;
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from: MyLibrary.MyProto
// Note: requires additional types generated from: MyExternalType.proto
namespace MyLibrary
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"MyProto")]
public partial class MyProto : global::ProtoBuf.IExtensible
{
public MyProto() {}
private readonly global::System.Collections.Generic.List<MyExternalType> _MyProperty = new global::System.Collections.Generic.List<MyExternalType>();
[global::ProtoBuf.ProtoMember(1, Name=@"MyProperty", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<MyExternalType> MyProperty
{
get { return _MyProperty; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
}