Add roundtrip test for Foo and Bar structs - #87
Conversation
- Define Foo and Bar structs with [StructLayout(LayoutKind.Sequential, Pack = 1)] and [ZeroSerializer] attributes in SerializationModels.cs. - Add SequentialPackOneFooBarRoundTrip test in SerializationTests.cs verifying exact hardcoded byte lengths (3 for BarView and 30 for FooView) and verifying roundtrip data integrity.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| public Bar G { get; set; } | ||
| public Bar H { get; set; } |
There was a problem hiding this comment.
| public Bar G { get; set; } | |
| public Bar H { get; set; } | |
| public byte G { get; set; } | |
| public Bar H { get; set; } | |
| public Bar I { get; set; } |
There was a problem hiding this comment.
Applied the suggested shape update to Foo in SerializationModels.cs and updated SequentialPackOneFooBarRoundTrip in SerializationTests.cs accordingly.
- Updated Foo struct in SerializationModels.cs to include byte property G and Bar properties H and I as suggested in PR review. - Updated SequentialPackOneFooBarRoundTrip in SerializationTests.cs to check expected byte lengths (3 for BarView and 31 for FooView) and full roundtrip serialization.
|
|
||
| [StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
| [ZeroSerializer] | ||
| public struct Foo |
There was a problem hiding this comment.
| public struct Foo | |
| public struct BadAlignedStructWithPackOne |
Rename Bar and test method name also.
There was a problem hiding this comment.
Renamed Bar to BadAlignedStructWithPackOne and updated test method name to BadAlignedStructWithPackOneRoundTrip as requested.
There was a problem hiding this comment.
Renamed Foo to BadAlignedContainerStructWithPackOne and Bar to BadAlignedStructWithPackOne as requested.
- Renamed Bar struct to BadAlignedStructWithPackOne in SerializationModels.cs and updated Foo struct properties H and I accordingly. - Renamed test method to BadAlignedStructWithPackOneRoundTrip in SerializationTests.cs.
- Renamed Foo to BadAlignedContainerStructWithPackOne and Bar to BadAlignedStructWithPackOne in SerializationModels.cs and updated SerializationTests.cs accordingly.
|
|
||
| [StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
| [ZeroSerializer] | ||
| public struct BadAlignedContainerStructWithPackOne |
There was a problem hiding this comment.
| public struct BadAlignedContainerStructWithPackOne | |
| public struct BadlyAlignedContainerStructWithPackOne |
There was a problem hiding this comment.
Renamed to BadlyAlignedContainerStructWithPackOne.
|
|
||
| [StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
| [ZeroSerializer] | ||
| public struct BadAlignedStructWithPackOne |
There was a problem hiding this comment.
| public struct BadAlignedStructWithPackOne | |
| public struct BadlyAlignedStructWithPackOne |
There was a problem hiding this comment.
Renamed to BadlyAlignedStructWithPackOne.
- Renamed BadAlignedStructWithPackOne to BadlyAlignedStructWithPackOne and BadAlignedContainerStructWithPackOne to BadlyAlignedContainerStructWithPackOne as record structs. - Added Materialize equality assertion (foo == view.Materialize()) to BadlyAlignedStructWithPackOneRoundTrip in SerializationTests.cs.
| I = new BadlyAlignedStructWithPackOne { A = 0xCD, B = -4321 } | ||
| }; | ||
|
|
||
| var buffer = new byte[BadlyAlignedContainerStructWithPackOneView.RequiredByteLength]; |
There was a problem hiding this comment.
| var buffer = new byte[BadlyAlignedContainerStructWithPackOneView.RequiredByteLength]; | |
| var array = new BadlyAlignedContainerArrayStructWithPackOne(); | |
| array.Values = new[] { default, foo, default }; | |
| var buffer = new byte[BadlyAlignedContainerStructWithPackOneView.RequiredByteLength * 3]; |
There was a problem hiding this comment.
Added BadlyAlignedContainerArrayStructWithPackOne model and updated array buffer setup.
|
|
||
| TestAssert.Equal(31, writtenBytes, nameof(writtenBytes)); | ||
|
|
||
| var view = new BadlyAlignedContainerStructWithPackOneView(buffer); |
There was a problem hiding this comment.
| var view = new BadlyAlignedContainerStructWithPackOneView(buffer); | |
| var second = buffer.AsMemory().Slice(BadlyAlignedContainerStructWithPackOneView.RequiredByteLength, BadlyAlignedContainerStructWithPackOneView.RequiredByteLength) | |
| var view = new BadlyAlignedContainerStructWithPackOneView(second); |
There was a problem hiding this comment.
Updated view initialization to slice directly from memory offset.
| var buffer = new byte[BadlyAlignedContainerStructWithPackOneView.RequiredByteLength]; | ||
| int writtenBytes = foo.Serialize(buffer); | ||
|
|
||
| TestAssert.Equal(31, writtenBytes, nameof(writtenBytes)); |
There was a problem hiding this comment.
| TestAssert.Equal(31, writtenBytes, nameof(writtenBytes)); | |
| TestAssert.Equal(93, writtenBytes, nameof(writtenBytes)); | |
| var arrayView = new BadlyAlignedContainerArrayStructWithPackOne(buffer); | |
| TestAssert.True(arrayView.Values[0] == default, "1st item"); | |
| TestAssert.True(arrayView.Values[2] == default, "3rd item"); |
There was a problem hiding this comment.
Updated array assertions in BadlyAlignedStructWithPackOneRoundTrip.
…test - Added BadlyAlignedContainerArrayStructWithPackOne model in SerializationModels.cs. - Updated BadlyAlignedStructWithPackOneRoundTrip in SerializationTests.cs to test array serialization and memory slicing as requested in PR review.
Adds a roundtrip unit test for Foo and Bar structs decorated with [StructLayout(LayoutKind.Sequential, Pack = 1)] and [ZeroSerializer], verifying hardcoded byte lengths (3 and 30) and roundtrip serialization correctness.
PR created automatically by Jules for task 6948808545237087535 started by @sator-imaging