Skip to content

Fix C# Compiler Parity and Descriptor Generation#30

Draft
google-labs-jules[bot] wants to merge 1 commit into
masterfrom
fix-csharp-compiler-15615303074311053390
Draft

Fix C# Compiler Parity and Descriptor Generation#30
google-labs-jules[bot] wants to merge 1 commit into
masterfrom
fix-csharp-compiler-15615303074311053390

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

This change addresses failures in ComprehensiveCSharpProtoParityTest by implementing missing features in the C# code generator and the underlying protobuf parser/compiler infrastructure.

Key changes:

  1. C# Generator: Added generation of the Reflection class, which contains the serialized FileDescriptorProto as a Base64 string. Implemented GeneratedClrTypeInfo generation. Added correct #pragma and #region blocks to match protoc output.
  2. Parser & Tokenizer: Modified Tokenizer to capture comments instead of discarding them. Updated Parser to use LocationRecorder correctly for nested elements (fields, nested messages, enums) and to attach captured comments to the SourceLocationTable.
  3. Compiler: Updated Compiler to attach the populated SourceCodeInfo (from SourceLocationTable) to the FileDescriptorProto before building the FileDescriptor.
  4. Code Generator Interface: Extended CodeGenerator interface to accept FileDescriptorProto in generate method. This is crucial because FileDescriptor.toProto() in protobuf-java tends to strip SourceCodeInfo, but the C# generator needs it to match protoc output (which includes comments in the descriptor data).
  5. Test Update: Fixed ComprehensiveCSharpProtoParityTest to correctly attach SourceCodeInfo when parsing protos in-memory, mirroring the fix in Compiler.

These changes ensure that the generated C# code structure matches the expected output from standard protoc and that the embedded descriptor data includes necessary metadata (like source locations/comments), bringing the compiler closer to full parity.


PR created automatically by Jules for task 15615303074311053390 started by @voidifremoved

- Implement Reflection class generation in C# output including Base64 descriptor data.
- Fix C# generator to output pragmas and regions.
- Update Tokenizer and Parser to capture comments and populate SourceLocationTable.
- Update Compiler to attach SourceCodeInfo to FileDescriptorProto.
- Update CodeGenerator interface to allow passing FileDescriptorProto to generators.
- Pass full FileDescriptorProto (with SourceCodeInfo) to CSharpCodeGenerator.
- Update ComprehensiveCSharpProtoParityTest to verify SourceLocationTable population.
@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.

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.

0 participants