What is the .proto equivalent of List <T> in protobuf-net?
To maintain some consistency, we use code generation for many of our object models, and one of the branches of this process generates .proto files for ProtocolBuffers through a separate generation module. However, at the moment I do not understand how to implement generation when this happens to an object List<T>.
This seems to be possible through contracts:
[ProtoMember(1)]
public List<SomeType> MyList {get; set;}
but outside of this, Iβm not sure how to do this, or only this can be done only when creating the .proto / file using the VS special tool. Any thoughts?
+3
1 answer
repeated SomeType MyList = 1;
, 100%, GetProto():
class Program
{
static void Main()
{
Console.WriteLine(Serializer.GetProto<Foo>());
}
}
[ProtoContract]
public class Foo
{
[ProtoMember(1)]
public List<Bar> Items { get; set; }
}
[ProtoContract]
public class Bar { }
:
message Foo {
repeated Bar Items = 1;
}
message Bar {
}
- , xslt .
+6