Skip to content

Commit eebaffe

Browse files
committed
[#12] NativeStructSizesTests: document why sizes are duplicated
Reviewer suggested sharing the storage-size literals between Iox2NativeMethods.cs and this test file. Doing so would erase the tripwire: Marshal.SizeOf<T> reads the StructLayout(Size = ...) attribute, so if both sides derive from the same const, the assert collapses to const-equals-const and trivially passes. The double-entry bookkeeping is the point — a maintainer who updates one side but forgets the other gets a failing test. Adding an in-line note so the design intent is visible at the literals, not buried in the class docstring.
1 parent 493c2de commit eebaffe

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/Ffi/NativeStructSizesTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ namespace Iceoryx2.Tests.Ffi;
2727
/// </summary>
2828
public class NativeStructSizesTests
2929
{
30+
// INTENTIONAL DUPLICATION of the Size attribute in Iox2NativeMethods.cs.
31+
// Sharing a single const between the StructLayout Size and the test would
32+
// make the assert trivially pass (both sides derive from the same value)
33+
// and erase the tripwire. The point of the duplication is double-entry
34+
// bookkeeping against the C header: if a maintainer updates one side but
35+
// forgets the other, this test fails.
3036
private const int ServiceBuilderStorageSize = 9104; // iceoryx2.h iox2_service_builder_storage_t
3137
private const int NodeBuilderStorageSize = 18696; // iceoryx2.h iox2_node_builder_storage_t
3238

0 commit comments

Comments
 (0)