I have the following Type:
Class Command<TData> : Base Where TData : I
In runtime this class is build (with specific TDATA) and Serialized. I have 2 issues( I'm using V2 ): 1) When I'm adding this type to runtime modal :
var meta = this._modal.Add(type, false)
.Add(this.GetDMProperties(type).Select(p => p.Name)
.ToArray());
I get the following exception:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at ProtoBuf.Meta.TypeModel.ResolveProxies(Type type) in C:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 952 at ProtoBuf.Meta.RuntimeTypeModel.FindWithoutAdd(Type type) in C:\Dev\protobuf-net\protobuf-net\Meta\RuntimeTypeModel.cs:line 118 at ProtoBuf.Meta.ValueMember..ctor(RuntimeTypeModel model, Type parentType, Int32 fieldNumber, MemberInfo member, Type memberType, Type itemType, Type defaul tType, DataFormat dataFormat, Object defaultValue) in C:\Dev\protobuf-net\protobuf-net\Meta\ValueMember.cs:line 75 at ProtoBuf.Meta.MetaType.AddField(Int32 fieldNumber, String memberName, Type itemType, Type defaultType, Object defaultValue) in C:\Dev\protobuf-net\protobu f-net\Meta\MetaType.cs:line 1165 at ProtoBuf.Meta.MetaType.Add(String[] memberNames) in C:\Dev\protobuf-net\protobuf-net\Meta\MetaType.cs:line 1046
2) If i try to skip it at start up and try to do it on demand like below:
if (this._modal.CanSerializeContractType(objectType) == false)
{
this._modal.Add(objectType, false);
this._modal.CompileInPlace();
}
CanSerializeContractType returns true, but in practice only the base data is serialized.
My question is what is the practice of adding this type to modal without adding all permutations on design time if possible ?
CanSerialize...
) - cannot reproduce either - here's my test - can you add any context to help me repro? Re the second, I wonder ifCanSerialize...
reports false initially, then youAdd
it, but you haven't added any members to serialize - is this the issue? – Marc Gravell♦type == T
, for no specificT
). I'll see what I can do (fixing that it easy - I mean more: thinking of a way to address the scenario) – Marc Gravell♦