The two-fold approach to arrays leads to a glaring issue (not really a bug).
Given this declaration
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public Substructure[] SomeMember {get;set;}
But the corresponding file metadata instead says that the member is not of cardinality 5, the generator will produce this kind of code:
{
var structure = new ...();
structure.SomeMember = new Substructure [5];
for (var i = 0; i < 5; ++i)
structure.SomeMember[i]= new Substructure();
// Deserialization happens now
structure.SomeMember[i] = reader.ReadArray<Substructure>(3);
// ...
return structure;
}
User code should never have to hardcode array sizes but instead use SomeMember.Length, which here will yield two extra elements.
This is an even more glaring issue when the declared structure has cardinality lower than what the file declares.
The two-fold approach to arrays leads to a glaring issue (not really a bug).
Given this declaration
But the corresponding file metadata instead says that the member is not of cardinality 5, the generator will produce this kind of code:
User code should never have to hardcode array sizes but instead use
SomeMember.Length
, which here will yield two extra elements.This is an even more glaring issue when the declared structure has cardinality lower than what the file declares.