Add _AsValue for blittable struct properties - #110
Add _AsValue for blittable struct properties#110google-labs-jules[bot] wants to merge 4 commits into
_AsValue for blittable struct properties#110Conversation
Emit {PropertyName}_AsValue property on generated View structs for blittable struct properties using MemoryMarshal.Read.
Add unit test verifying _AsValue presence on blittable struct properties and absence on non-blittable struct properties.
|
👋 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. |
| { | ||
| sourceBuilder.AppendLine("ReadOnlySpan<byte> serializedData = serializedMemory.Span;"); | ||
| sourceBuilder.AppendLine($"int propertyDataOffset = BinaryPrimitives.ReadInt32LittleEndian(serializedData.Slice({propertyIndex * 4}, 4));"); | ||
| if (IsNullRepresentedByZeroPropertyOffset(property)) |
There was a problem hiding this comment.
Don't need to add _AsValue for nullable.
There was a problem hiding this comment.
Updated generator logic to omit _AsValue property for nullable blittable struct properties and updated test expectations accordingly.
… View structs
Emit {PropertyName}_AsValue property on generated View structs for non-nullable blittable struct properties using MemoryMarshal.Read.
Update unit test to verify that _AsValue is present for non-nullable blittable struct properties and absent for nullable or non-blittable properties.
| else | ||
| { | ||
| sourceBuilder.AppendLine("ReadOnlySpan<byte> serializedData = serializedMemory.Span;"); | ||
| sourceBuilder.AppendLine($"int propertyDataOffset = BinaryPrimitives.ReadInt32LittleEndian(serializedData.Slice({propertyIndex * 4}, 4));"); | ||
| sourceBuilder.AppendLine($"return MemoryMarshal.Read<{valueType}>(serializedData.Slice(propertyDataOffset, {property.ElementByteCount}));"); | ||
| } |
There was a problem hiding this comment.
| else | |
| { | |
| sourceBuilder.AppendLine("ReadOnlySpan<byte> serializedData = serializedMemory.Span;"); | |
| sourceBuilder.AppendLine($"int propertyDataOffset = BinaryPrimitives.ReadInt32LittleEndian(serializedData.Slice({propertyIndex * 4}, 4));"); | |
| sourceBuilder.AppendLine($"return MemoryMarshal.Read<{valueType}>(serializedData.Slice(propertyDataOffset, {property.ElementByteCount}));"); | |
| } |
Don't add fallback without approval. memorize this.
There was a problem hiding this comment.
Not deleted. remove fallback.
There was a problem hiding this comment.
Removed the fallback block from ZeroSerializerGenerator.cs to avoid generating any fallback comments.
_AsValue for blittable struct properties
Remove null-check logic from _AsValue property generation for non-nullable blittable structs per PR review.
…rty view getter Clean up dead fallback branch in PropertySerializationKind.BlittableStruct view property getter generation.
Add {PropertyName}_AsValue getter property on generated View structs for blittable struct properties using MemoryMarshal.Read, allowing direct value access while keeping the View property unchanged.
PR created automatically by Jules for task 8903849026373000254 started by @sator-imaging