atilaneves / cerealed

Powerful binary serialisation library for D
BSD 3-Clause "New" or "Revised" License
92 stars 3 forks source link

ArrayLength attribute doesn't work properly on char[] array #14

Open togrue opened 8 years ago

togrue commented 8 years ago

The following Testcase fails at runtime:

struct TestStruct {
    ubyte len;
    @ArrayLength("len") char[] foo;
}

auto decerealiser = Decerealiser([2, 1, 2]);
// CerealException: "@ArrayLength of 2 units of type dchar (4 bytes) larger than remaining byte array (2 bytes)"
auto ts = decerealiser.value!TestStruct;
assert(ts.foo == ['\x01', '\x02']);
assert(ts.foo.length == 2);
atilaneves commented 8 years ago

I think you can blame this one on auto-decoding. I suggest using ubyte instead.