"Unable to deserialize unbalanced list" when IReadOnlyList<> has less than the exepected number of items.
Environment:
Windows 10, 64-bit
OpenTAP 9.15.0 Editor 9.15.0
Steps to reproduce:
With 9.14.1 it was possible to deserialize XML when fewer items were an IReadOnlyList than expected.
[Display("Tx Command Sequences", "A predefined list of TX command sequences to control the DUT.", Order: 10.2)]
public IReadOnlyList<TxCommandObject> CmdObj { get; set; } = new List<TxCommandObject>
{
new TxCommandObject() {CmdType = CommandSequenceTypeEnum.TxStart, Cmds = new List<Commands>()},
new TxCommandObject() {CmdType = CommandSequenceTypeEnum.TxPower, Cmds = new List<Commands>()},
new TxCommandObject() {CmdType = CommandSequenceTypeEnum.TxOff, Cmds = new List<Commands>()},
new TxCommandObject() {CmdType = CommandSequenceTypeEnum.AfterTxOn, Cmds = new List<Commands>()},
}.AsReadOnly();
Actual result:
With 9.15.0 this is a breaking change that is not backwards compatible. If mdObj shown only has three items an exception is now thrown.
00:49:41.442 Serializer XML line 14 column 14: Unable to set property 'CmdObj'.
00:49:41.442 Serializer Error was: "Unable to deserialize unbalanced list".
00:49:41.444 Serializer Exception: Unable to deserialize unbalanced list
00:49:41.445 Serializer at OpenTap.Plugins.CollectionSerializer.Deserialize(XElement element, ITypeData _t, Action`1 setResult)
00:49:41.445 Serializer at OpenTap.TapSerializer.Deserialize(XElement element, Action`1 setter, ITypeData t)
00:49:41.445 Serializer at OpenTap.Plugins.ObjectSerializer.TryDeserializeObject(XElement element, ITypeData t, Action`1 setter, Object newobj, Boolean logWarnings)
00:49:41.454 Serializer Exception caught at:
00:49:41.461 Serializer at Boolean Deserialize(System.Xml.Linq.XElement, OpenTap.ITypeData, System.Action`1[System.Object])
00:49:41.461 Serializer at Boolean Deserialize(System.Xml.Linq.XElement, System.Action`1[System.Object], OpenTap.ITypeData)
00:49:41.461 Serializer at Boolean Deserialize(System.Xml.Linq.XElement, OpenTap.ITypeData, System.Action`1[System.Object])
00:49:41.461 Serializer at Boolean Deserialize(System.Xml.Linq.XElement, System.Action`1[System.Object], OpenTap.ITypeData)
00:49:41.461 Serializer ...
Question:
- Is this a result of the recent update that prevents IReadonly items to be deleted?
Edited by Jason Hicks