Hi I'm working on updating to a newer version of protobuf-net (2.3.17 -> 3.0.62), but am running into an issue serializing classes that have a field that is a collection that contains another collection (ex: Dictionary<int, Dictionary<int, int>>) When creating and compiling a TypeModel, the TypeModel returned by TypeModel.Compile() will throw an InvalidOperationException - No serializer for type System.Collections.Generic.Dictionary`2[System.Int32,System.Int32] is available for model CompiledModel... when trying to serialize this field.
This worked previously, but appears to have broken with version 3.0.
Here's an example I wrote up in linqpad that reproes the problem:
void Main()
{
RuntimeTypeModel newTypeModel = RuntimeTypeModel.Create();
newTypeModel.Add(typeof(TestClass), applyDefaultBehaviour: true);
var compiledModel = newTypeModel.Compile();
var testObj = new TestClass();
testObj.Data = new Dictionary<int, Dictionary<int, int>>();
using (var ms = new MemoryStream())
{
compiledModel.Serialize(ms, testObj);
byte[] data = ms.ToArray();
data.Dump();
}
}
[ProtoContract]
public class TestClass : Extensible
{
[ProtoMember(1)]
public Dictionary<int, Dictionary<int, int>> Data { get; set; }
}
Is this kind of workflow deprecated in 3.0 and beyond?