[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)

* WIP: Fix returned truncated ArraySegment<byte> if elementSize is not byte

* Fix

* Regenerated test code
This commit is contained in:
Björn Harrtell
2021-02-23 18:34:20 +01:00
committed by GitHub
parent ffc2ef77ca
commit cbbbaa61b3
7 changed files with 24 additions and 19 deletions

View File

@@ -112,7 +112,7 @@ namespace FlatBuffers
// Get the data of a vector whoses offset is stored at "offset" in this object as an
// ArraySegment&lt;byte&gt;. If the vector is not present in the ByteBuffer,
// then a null value will be returned.
public ArraySegment<byte>? __vector_as_arraysegment(int offset)
public ArraySegment<byte>? __vector_as_arraysegment(int offset, int elementSize)
{
var o = this.__offset(offset);
if (0 == o)
@@ -122,7 +122,7 @@ namespace FlatBuffers
var pos = this.__vector(o);
var len = this.__vector_len(o);
return bb.ToArraySegment(pos, len);
return bb.ToArraySegment(pos, len * elementSize);
}
#endif