Open GoogleCodeExporter opened 9 years ago
I too have been having trouble with IgnoreListHandling today. Simple test
example below:
namespace Tensys.Dev
{
using System.Collections.Generic;
using ProtoBuf;
using System.Diagnostics;
internal class Program
{
[ProtoContract]
public class OuterList
{
[ProtoMember(1)]
public readonly List<InnerList> regionData = new List<InnerList>();
}
[ProtoContract(IgnoreListHandling = true)]
public class InnerList : IEnumerable<int>
{
[ProtoMember(1)]
public readonly List<int> data = new List<int>();
public IEnumerator<int> GetEnumerator()
{
return data.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public bool Add(int item)
{
this.data.Add(item);
return true;
}
}
private static void Main(string[] args)
{
var outerList = new OuterList();
var innerList = new InnerList();
innerList.Add(1);
innerList.Add(2);
outerList.regionData.Add(innerList);
var info = ProtoBuf.Meta.RuntimeTypeModel.Default[typeof(InnerList)];
Debug.Assert(info.IgnoreListHandling == true); //OK
var listClone = ProtoBuf.Serializer.DeepClone(innerList); //OK
var testClone = ProtoBuf.Serializer.DeepClone(outerList); //Fails : Nested or jagged lists and arrays are not supported
}
}
}
Original comment by tom.ma...@gmail.com
on 9 May 2013 at 4:02
I've also had problems with the "Nested or jagged lists and arrays are not
supported" exception being thrown by nested lists where the inner list has the
IgnoreListHandling attribute.
I've attached a fix to check for the attribute on inner lists before throwing
the NotSupportedException.
Original comment by ppo4...@gmail.com
on 6 Jun 2014 at 12:34
Attachments:
Original issue reported on code.google.com by
mdonou...@gmail.com
on 19 Apr 2012 at 7:13Attachments: