jefffhaynes / BinarySerializer

A declarative serialization framework for controlling formatting of data at the byte and bit level using field bindings, converters, and code.
MIT License
292 stars 62 forks source link

Different behaviour of FieldCount and FiledLength on double array #156

Closed A016699 closed 4 years ago

A016699 commented 4 years ago

Hello, If I'm using the FieldLength attribute for an double array the stream position after de-serialization is wrong. If I'm using the FieldCount the position is correct.

Hier are the class I'm using :

    {
        [FieldOrder(0)]
        public int Length { get; set; }
        [FieldOrder(10)]
        [FieldLength(nameof(Length))]
        public double[] Data { get; set; }
    }

If the Length Property = 10 the File position after reading should 84 but I'm getting 14 (am attached the small test program) Program.zip

It also looks like that it is not working for float and long.

jefffhaynes commented 4 years ago

That's correct. FieldLength refers to byte length, not array count. I think you want FieldCount.

A016699 commented 4 years ago

Thanks Jeff for clarifying. May you should explizit mention that at your documentation.