Skip to content

Add _AsValue for blittable struct properties - #110

Draft
google-labs-jules[bot] wants to merge 4 commits into
mainfrom
feature/blittable-struct-as-value-8903849026373000254
Draft

Add _AsValue for blittable struct properties#110
google-labs-jules[bot] wants to merge 4 commits into
mainfrom
feature/blittable-struct-as-value-8903849026373000254

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

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

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.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Comment thread src/ZeroSerializerGenerator.cs Outdated
{
sourceBuilder.AppendLine("ReadOnlySpan<byte> serializedData = serializedMemory.Span;");
sourceBuilder.AppendLine($"int propertyDataOffset = BinaryPrimitives.ReadInt32LittleEndian(serializedData.Slice({propertyIndex * 4}, 4));");
if (IsNullRepresentedByZeroPropertyOffset(property))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to add _AsValue for nullable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Comment on lines +1366 to +1371
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}));");
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not deleted. remove fallback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the fallback block from ZeroSerializerGenerator.cs to avoid generating any fallback comments.

@sator-imaging sator-imaging changed the title Add _AsValue for blittable struct properties Add _AsValue for blittable struct properties Aug 31, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant