mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-03 19:24:12 +00:00
Correct span and non-span versions of ToArray() and ToArrayPadded() methods (#8734)
* Correction of bug inside ToArray<T> methods Avoid allocating too large buffers (len is expressed in bytes, not in Ts). Added validation to ensure len is a multiple of SizeOf<T>() before converting to array. * Update ByteBuffer.cs * Refactor ToArray and ToArrayPadded methods I understand from failed test that pos, len, padLeft and padRight are expressed in Ts * Refactor ToArray and ToArrayPadded methods * Final correction All functions parameters expressed in bytes for homogeneity Tests run: - UNSAFE_BYTEBUFFER=true/ENABLE_SPAN_T=true: passed - UNSAFE_BYTEBUFFER=true/ENABLE_SPAN_T=false: passed - UNSAFE_BYTEBUFFER=false/ENABLE_SPAN_T=false: passed - UNSAFE_BYTEBUFFER=false/ENABLE_SPAN_T=true: configuration forbidden by compilation Correction of FlatBuffers.Test.csproj to allow UNSAFE_BYTEBUFFER/ENABLE_SPAN_T tests Correction of FlatBuffersExampleTests.cs: I think the test was not run because it could not pass (to be reviewed carefully)
This commit is contained in:
@@ -9,12 +9,12 @@
|
||||
<Compile Remove="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(UnsafeByteBuffer)' == 'true'">
|
||||
<PropertyGroup Condition="'$(UNSAFE_BYTEBUFFER)' == 'true'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(EnableSpanT)' == 'true'">
|
||||
<PropertyGroup Condition="'$(ENABLE_SPAN_T)' == 'true'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>$(DefineConstants);ENABLE_SPAN_T</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user