Closed bevanweiss closed 1 year ago
I think the issue here is that the BoundedStream isn't masking the value before OR'ing it into the _bitBuffer.
If I mask these bits then there's a failing test in the LengthTest however. The Internal2 is currently expected to serialize to 0xAA, which I think is incorrect, since the inner field is defined as BitLength(4), so it should only fill 4 bits of the byte.
Perhaps this is just me expecting something that isn't quite right. But my thought here is that if I define a Field as being 4 bits long, then it shouldn't be allowed to exceed that length, regardless of what value is attempted to be assigned to it in the deserialized form.
I've got a short little test case below that illustrates this. It uses the existing BitLengthTest class (and the InternalBitLengthValueClass as the simplest example). This class is defined with two members, each with 4 bits to make up a single byte.
The result from the test case is as below
This appears to show the serialized field being allowed to extend beyond the 4 bits it's defined as.
My expectation is that the result is the bit mask of the bits defined for the field, and the value applied to the member. This would be consistent with things like: