protobuf-net

Protobuf-net & IL2CPP - System.Reflection.Emit is not supported

£可爱£侵袭症+ 提交于 2019-12-13 03:18:26
问题 I have a problem with the protobuf-net and Android app built with IL2CPP. Everything worked fine when I used MONO instead of IL2CPP for development. Now I need to use IL2CPP for x64 support. I didn't know System.Reflection.Emit is not supported with IL2CPP and protobuf-net is using it. Is there a way to make the protobuf-net work with IL2CPP? 回答1: I got same problem on iOS. You have to compile ProtoModel before. using Assembly = UnityEditor.Compilation.Assembly; private static void

Custom serialization/deserialization methods in protobuf-net

故事扮演 提交于 2019-12-13 02:29:16
问题 Is it possible to supply your own methods for serializing and deserializing a type for protobuf-net to use in its' Serializer.Serialize() and Serializer.Deserialize() methods? i.e. Write my own code using ProtoWriter and ProtoReader, instead of marking up the class with serialization attributes. 回答1: The mention of ProtoReader / ProtoWriter means this is a "v2" question, in which case you don't have to use the attributes at all - you can define the model at runtime via TypeModel . Re the

Protobuf-net fails to deserialize Guid

早过忘川 提交于 2019-12-13 01:34:53
问题 Im hosting a WCF service on top of IIS 7.5 & using protobuf-net bindings. I have a data contract with a Guid type property : [Datacontract(Namespace = "http://lorem")] public class MyCustomData { [DataMember(Order = 0)] public Guid Id { get; set; } // this ends up as empty, ie. 0000-0000-.... [DataMember(Order = 1)] public int MyInt { get; set; } // serializes/deserializes ok } [ServiceContrac(Namespace = "http://ipsum"), Protobuf.ProtoContract] public interface IMyService { ... }

protobuf-net can't send Negative number

牧云@^-^@ 提交于 2019-12-13 00:37:23
问题 [Required] [DefaultValue(-1)] public int MvcUserId { get; set; } when I set MvcUserId =-1; but I will get MvcUserId =0; if i use json serlize the object ,everything will be ok. 回答1: You need to actually apply the default : [Required] [DefaultValue(-1)] public int MvcUserId { get; set; } = -1; Without that protobuf-net ignores the value on send (because it is the default), and on receive there is nothing to process . protobuf-net assumes that your code correctly applies the defaults. 来源: https

Protobuf data serializer

泄露秘密 提交于 2019-12-12 22:48:22
问题 this dataserializer is great for performance. but I keep getting stuck on datacolumns that has datatype of System.Object causing the serializer to throw an exception:Cannot serialize data column of type 'System.Object'. is there any way around it? 回答1: The protobuf format is designed to suit scenarios where the data is predictable to the receiver, and does not suit "object" scenarios very well, however, depending on the data layout a few things are possible: if the "object" data is a nested

protobuf.net not serializing zero

自古美人都是妖i 提交于 2019-12-12 21:05:20
问题 It looks like there is an encoding problem for 0 as Int64. Other values as Int64 ok. [ProtoMember(3)] private readonly Int64 _intValue is deserialized as Int64.MinValue Any idea? I confirm the bug. This class will not serialize properly if _val == 0 [ProtoContract] class VerySimple { [ProtoMember(1)] private readonly Int64 _val = Int64.MinValue; public VerySimple(long val) { _val = val; } public long Val { get { return _val; } } public VerySimple() { } } this test fails [Test] public void

How to convert existing POCO classes in C# to google Protobuf standard POCO

*爱你&永不变心* 提交于 2019-12-12 19:26:42
问题 I have POCO classes , I use NewtonSoft json for seralization. Now i want to migrate it to Google protocol buff. Is there any way i can migrate all my classes (not manually) so that i can use google protocol buff for serialization and deseralization. 回答1: Do you just want it to work? The absolute simplest way to do this would be to use protobuf-net and add [ProtoContract(ImplicitFields = ImplicitFields.AllPublic)] . What this does is tell protobuf-net to make up the field numbers , which it

How to implement protocol buffers (de)serialization on a Java client talking to a .NET server utilizing protobuf-net v2?

久未见 提交于 2019-12-12 19:12:24
问题 If I understand it correctly, the Java end needs the respective .proto file. However, it is unclear to me how to generate one from the RuntimeTypeModel instance (protobuf-net v2) used on the server side. Thanks. 回答1: At current, it simply hasn't been re-written; there is a v1 version of GetProto() , however it won't apply to v2 as it needs to be heavily refactored to work from RuntimeTypeModel . It is simply a case of finding time to put the code together. If the model is moderately sized, I

how to use extensions from protocol buffers to maintain 'general' message

孤人 提交于 2019-12-12 18:05:04
问题 My client-server communication looks like this: there are some so called annoucements which are seperate messages used to exchange information. The idea is that annoucement is the common part of every message. Actually I suppose it will be the type of the message. The type decide what is the content. In UML class diagram Annoucement would be the class all other messages inherit. I want to implement that idea in communication between two applications one written in C++ the other in C#. I

Conditional serialization with protobuf-net

 ̄綄美尐妖づ 提交于 2019-12-12 17:19:58
问题 Is it possible to conditionally serialize a property from an object using protobuf-net? 回答1: protobuf-net supports the standard conditional serializers patterns, so for property Foo , a method like bool ShouldSerializeFoo() or a property bool FooSpecified (with at least a getter) should work fine. These same techniques are supported my multiple serialization and UI frameworks. Or more simply, for value-type properties, you can just use Nullable<T> . A null value will not be serialized. 来源: