I'm using protobuf-net (version 2.0.0.621) and having a problem serializing List type where T is my own class (it does't matter what it contains) and a surrogate is set for T.
The surrogate is set like this:
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MyClass), false).SetSurrogate(typeof(MyClassSurrogate));
MyClass:
public class MyClass
{
public int Number { get; set; }
}
[ProtoContract]
MyClassSurrogate
{
[ProtoMember(1)]
public int Number { get; set; }
}
Then I create a generic list of type MyClass instance, fill it with items and serialize it like this:
ProtoBuf.Serializer.Serialize(stream, list);
The problem occurs on deserialization, I keep getting "null" in the surrogate in the implicit operator conversion:
static public implicit operator MyClassSurrogate(MyClass myClass)
then 'myClass' is null.
If I remove the surrogate and decorate MyClass with the proto attributes, everything works fine.
Can you tell me what I'm doing wrong?
Thanks.