Open GoogleCodeExporter opened 9 years ago
C type does not need to have A field. Is enough to have only IA field. Maybe
this will simplify the testing scenario.
Original comment by alexandr...@gmail.com
on 5 Sep 2011 at 8:07
I shall investigate
Original comment by marc.gravell
on 5 Sep 2011 at 12:51
I hit this too. It seems if I serialize the concrete class first, I cannot
serialize the interface that the concrete class implements afterwards. The
following code shows the problem. The problem goes away if I switch the order
of serialization (i.e. serialize T first and Foo second).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProtoBuf;
using System.IO;
namespace ProtoBufTest
{
[ProtoContract, ProtoInclude(100, typeof(Foo))]
public interface IFoo
{
int A { get; }
}
[ProtoContract]
public struct Foo : IFoo
{
[ProtoMember(1)]
public int a;
public Foo(int a)
{
this.a = a;
}
public int A
{
get
{
return a;
}
}
}
[ProtoContract]
public class T
{
[ProtoMember(1)]
public IFoo f;
}
class Program
{
static void Main(string[] args)
{
using (MemoryStream ms = new MemoryStream())
{
Foo f = new Foo(3);
Serializer.Serialize(ms, f);
}
using (MemoryStream ms = new MemoryStream())
{
T t = new T();
t.f = new Foo(2);
Serializer.Serialize(ms, t);
}
}
}
}
Original comment by MingyuT...@gmail.com
on 25 Sep 2012 at 6:53
Original issue reported on code.google.com by
alexandr...@gmail.com
on 5 Sep 2011 at 8:04