From:
http://stackoverflow.com/questions/6174298/protobuf-v2-beta-2-false-positive-rec
ursion-error
Hello,
I'm getting a **ProtoBuf.ProtoException : Possible recursion detected** while
serializing a simple tree.
Tree code:
[ProtoContract]
[ProtoInclude(10, typeof(BinaryNode))]
public class Node
{
}
[ProtoContract]
public class BinaryNode : Node
{
[ProtoMember(1, IsRequired = true)] public Node Left { get; set; }
[ProtoMember(2, IsRequired = true)] public Node Right { get; set; }
}
Serialization code:
BinaryNode head = new BinaryNode();
BinaryNode node = head;
// 13 is the magic limit that triggers recursion check
for (int i = 0; i < 13; ++i)
{
node.Left = new BinaryNode();
node = (BinaryNode)node.Left;
}
Serializer.Serialize(new MemoryStream(), head);
Please note that I'm new to protobuf, so I'm maybe missing something obvious :-)
Original issue reported on code.google.com by marc.gravell on 30 May 2011 at 9:12
Original issue reported on code.google.com by
marc.gravell
on 30 May 2011 at 9:12