protobuf-net

protobuf-net: inheritance in C# but not in wire-format

青春壹個敷衍的年華 提交于 2019-12-11 10:56:33
问题 I get that protobuf do not support inheritance, and since I am using protoc-c on another end, I do not want to use any extensions as well. However, I am stuck with a C# model that depends on inheritance: class Header { public int version { get; set; } } class Message : Header { public String message { get; set; } } I attempted to switch the inheritance into encapsulation in the wire format to something like this: [ProtoContract] class Header { [ProtoMember(1)] public int version { get; set; }

Order of deserialization in protobuf-net

我的梦境 提交于 2019-12-11 10:47:28
问题 What's the order of deserialization of members in protobuf-net? Is it in order of tag numbers, in order of declaration, something else, or not guaranteed? I'm relying on this for my workaround for the problem where protobuf-net doesn't support most types of jagged arrays. I have a custom LinearAdapter class that presents the jagged array as an IEnumerable<T> (with an Add method). My main data representation is padded with zeros at the sides, with a variable padding size, so, on deserializing,

Protobuf-net null/empty lists and reference equality

核能气质少年 提交于 2019-12-11 10:28:36
问题 How can I configure the protobuf-net typemodel to pass the 3 unit tests in the example below? Protobuf version is v2 r470. I have looked at the list tests in the svn tree briefly but can't spot the difference between this and the null vs empty tests in protobuf-net svn. using System; using System.Collections.Generic; using System.Linq; using System.Text; using NUnit.Framework; using ProtoBuf; using ProtoBuf.Meta; namespace ProtoCollections { [TestFixture] public class CollectionTests { [Test]

nuget - Reference specific framework version from installed package?

徘徊边缘 提交于 2019-12-11 10:12:14
问题 This scenario goes a bit against the whole way nuget works so what i might be asking for is a hack... My problem: I need to have Restsharp and Protobuf-net referred to in a .net assembly that going into SQL-CLR for Server 2008 (so max .net 3.5, framework 2.0). Restsharp goes back to 3.5 as the lowest supported fwk version. Protobuf-net 3.5 onwards has a lot of gunk referring to system.servicemodel (and WCF) which i don't need and use and actively want to remove because it causes issues with

Does protobuf-net support Windows RT?

无人久伴 提交于 2019-12-11 10:07:55
问题 Is it possible to use the protobuf-net library in an application that targets Windows RT? I tried adding it via NuGet to my project but I receive this error: Successfully installed 'protobuf-net 2.0.0.480'. Successfully uninstalled 'protobuf-net 2.0.0.480'. Install failed. Rolling back... Could not install package 'protobuf-net 2.0.0.480'. You are trying to install this package into a project that targets '.NETCore,Version=v4.5', but the package does not contain any assembly references that

Serialize hashtable using Protocol Buffers (.NET)

僤鯓⒐⒋嵵緔 提交于 2019-12-11 08:22:27
问题 I am trying to serialize/deserialize my custom class which contains hashtable property using protobuf-net v2. [ProtoContract] public class MyClass { [ProtoMember(1)] public Hashtable MyHashTable { get; set; } } When I call Serializer.Serialize(...) exception appears: No serializer defined for type: System.Collections.Hashtable I try to modify: [ProtoContract] public class MyClass { [ProtoMember(1, DynamicType = true)] public Hashtable MyHashTable { get; set; } } But I have another exception:

Help needed with the most trivial protobuf-net example 4

你。 提交于 2019-12-11 08:06:30
问题 [DataContract] public class I<TId> { [DataMember(Order = 1)] public TId Id { get; set; } } [DataContract] public class J : I<int> { [DataMember(Order = 1)] public string Description { get; set; } } class Program { static void Main() { var o = new J { Id = 5, Description = "xa-xa", }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, o); ms.Position = 0; var o2 = Serializer.Deserialize<J>(ms); Debug.Assert(o.Id == o2.Id); } } } Why does the assertion fail and how to fix it? Thanks

How do I use protobuf-net in Silverlight WCF generated service

牧云@^-^@ 提交于 2019-12-11 06:23:56
问题 I try to use protobuf-net in WCF/Silverlight application to improve large objects array serialization performance. I can serialize/deserialize classes (added Order=, etc) in the service code. But when I try to apply ProtoBehavior, and call the protobuf-enabled service method from Silverlight, I get nulls instead of data (or errors). I think this is because: ProtoBehavior is lost in Silverlight-generated service code; Domain classes (types) are not in the re-used assembly, they're regenerated

C++ equivalent to SerializeWithLengthPrefix

孤街浪徒 提交于 2019-12-11 06:12:56
问题 I built a communication library using Protocol Buffers (protobuf-net) using Sockets (TcpListener and TcpClient) and it is working fine, but now a co-worker needs to write a library to communicate with my software using C++. Turns out that I'm using the Serializer.NonGeneric.SerializeWithLengthPrefix and Serializer.NonGeneric.TryDeserializeWithLengthPrefix . Are there equivalent functions in the protobuf C++ libraries? If not, anyone knows how to implement it, or have it implemented to share?

Data Member Order is missing from wcf client proxy generated class

隐身守侯 提交于 2019-12-11 04:28:28
问题 Have mapped table from sql database to linq in Employee dbml file. [global::System.Runtime.Serialization.DataContractAttribute()] public partial class tbEmployee { private int _Employeeid; private string _EmployeeName; public tbEmployee() { } [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Employeeid", DbType = "Int NOT NULL")] [global::System.Runtime.Serialization.DataMemberAttribute(Order = 0)] public int EmployeeID { get { return this._PeriodContextRefId; } set { if ((this.