How do I declare a C# property which uses a lambda return method in ProtoBuf?
I have a C# class which I am making into a ProtoBuf class. The class is structured as followed:
[ProtoContract]
public class TestClass : TestBaseClass
{
[ProtoMember(1)]
public int Age {get; set};
[ProtoMember(2)]
public string Name {get; set;}
[ProtoMember(3)]
public AnimalClass Animal {get; set; }
[ProtoMember(4)]
protected internal override long? AnimalId => Animal?.TestAnimalId;
}
I am trying to Serialize this class using the ProtoBuf.Serializer.Serialize() function. This is done in the following class:
public byte[] TestSerialize(object obj)
{
using (var memory = new MemoryStream())
{
ProtoBuf.Serializer.Serialize(memory, obj);
return memory.ToArray();
}
}
However, I am receiving a 'System.InvalidOperationException' during serialization, stating that it cannot make the change to 'AnimalId'. How would I serialize this class to a byte array?
from Recent Questions - Stack Overflow https://ift.tt/3b7Ltxd
https://ift.tt/eA8V8J
Comments
Post a Comment