protocol-buffers

Protobuf-net fails to serialize property with only getter - Cannot apply changes to property

风格不统一 提交于 2019-12-18 06:37:22
问题 I am using protobuf-net to serialize an object and I get exception: Cannot apply changes to property TestProject.TestMessage.ClientId with stacktrace: at ProtoBuf.Serializers.PropertyDecorator.SanityCheck(TypeModel model, PropertyInfo property, IProtoSerializer tail, Boolean& writeValue, Boolean nonPublic, Boolean allowInternal) at ProtoBuf.Serializers.PropertyDecorator..ctor(TypeModel model, Type forType, PropertyInfo property, IProtoSerializer tail) at ProtoBuf.Meta.ValueMember

How to compile multiple proto files in single command?

余生颓废 提交于 2019-12-18 03:25:09
问题 I have two proto files inside single directory and I am looking for a way to generate classes from those files in single command. Protobuf documentation says that we need to use --proto_path argument for this. C:\shekhar\proto_trial>dir Volume in drive C is C Directory of C:\shekhar\proto_trial 07/25/2014 12:16 PM <DIR> . 07/25/2014 12:16 PM <DIR> .. 07/25/2014 12:16 PM <DIR> java_op 07/25/2014 12:16 PM 230 map.proto 07/23/2014 04:24 PM 161 message.proto 07/25/2014 12:17 PM 1,228 response

protobuf-net serializing object graph

十年热恋 提交于 2019-12-18 02:18:32
问题 If I have object A and B both contain some field serialized field F, and both point to the same serializable object C. Does protobuf-net serialize by reference or serialize by value? When the object graph is deserialized, does protobuf-net generate 2 separate objects for A.F and B.F? I'm asking because I want to know if serialization preserves reference equality. 回答1: The raw "protobuf" spec, a defined by Google, is a tree serializer (like XmlSerializer). So by default you would get C

Generic Parsing of PB in java

烈酒焚心 提交于 2019-12-17 23:25:39
问题 Is it possible to parse protobuf in a generic fashion in Java? I have looked into GeneratedMessage and could not find a way to parse any PB byte buffer into a GeneratedMessage. Essentially, I am trying to parse a PB byte buffer into GeneratedMessage and then I would use reflection to detect fields inside it. 回答1: First of all, you can't parse PB data without knowing the schema. The schema originally comes from a ".proto" file and is typically embedded in the code generated by protoc . However

Google protocol buffers compare

爷,独闯天下 提交于 2019-12-17 22:45:09
问题 I want to compare two Messages or (two sub parameters) of Google protocol buffers. I don't find an API to achieve it. Any ideas? 回答1: You can use the class google::protobuf::util::MessageDifferencer for this. I think it's only available since v3.0.2: Introduced new utility functions/classes in the google/protobuf/util directory: MessageDifferencer: compare two proto messages and report their differences. MessageDifferencer::Equals(msg1, msg2); 回答2: Instead of using message.DebugString you

Automatically generate Java from .proto with maven/m2e in Eclipse IDE

不想你离开。 提交于 2019-12-17 22:25:37
问题 For my team, I'd like to configure maven/eclipse build to automatically generate Java code from *.proto files (in a project that uses gRPC). Currently one needs to run mvn generate-source or mvn protobuf:compile (as in plugin usage page). Or what is the same add Run configuration to invoke maven goal compile . Whenever Eclipse Maven project is refreshed ( Alt + F5 ) or IDE is restarted, project is rebuilt but without what should appear in target/generated , thus turning project into red. So

How to change the buffer limit in Google's protobuf?

元气小坏坏 提交于 2019-12-17 19:02:10
问题 I'm getting this warning and an error afterwards when I try to parse a large message. I know than 64MB which is the default limit. I am using message.ParseFromIstream now. Does any one know to get access to CodedInputStream object to call the SetTotalBytesLimit function? or any other way to solve this problem? Reading dangerously large protocol message. If the message turns out to be larger than 67108864 bytes, parsing will be halted for security reasons. To increase the limit (or to disable

protobuf-net inheritance

♀尐吖头ヾ 提交于 2019-12-17 18:25:03
问题 Marc mentioned on stackoverflow that it will be possible in v2 of protobuf-net to use ProtoInclude attribute (or similar approach) to serialize/deserialize class hierarchy without a need to specify each subtype in the base class. Is this implemented yet? We have a plugin interface that can be derived in external libraries, so there is no way of knowing what the derived types will be. We could maintain unique numbering between types though, but I couldn’t find any examples on the net, short of

Deserialize unknown type with protobuf-net

荒凉一梦 提交于 2019-12-17 10:38:22
问题 I have 2 networked apps that should send serialized protobuf-net messages to each other. I can serialize the objects and send them, however, I cannot figure out how to deserialize the received bytes . I tried to deserialize with this and it failed with a NullReferenceException. // Where "ms" is a memorystream containing the serialized // byte array from the network. Messages.BaseMessage message = ProtoBuf.Serializer.Deserialize<Messages.BaseMessage>(ms); I am passing a header before the

What does the protobuf text format look like?

不问归期 提交于 2019-12-17 10:16:29
问题 Google Protocol Buffers can not only be serialized in binary format, also be serialized as text. However I can't easily find examples of such text; what would it look like? Expected answer: an example covering all features allowed by the protobuf IDL/proto file including a sample protobuf packet in textual form. 回答1: Done myself: test.proto enum MyEnum { Default = 0; Variant1 = 1; Variant100 = 100; } message Test { required string f1 = 1; required int64 f2 = 2; repeated uint64 fa = 3;