C#: decompose CsDocComment.DocComment over RPC via a proper visitor#7894
Merged
Conversation
CSharpSender.visitSpace threw IllegalArgumentException when a Space contained a parsed CsDocComment.DocComment (produced by a CSharpVisitor pass) because only TextComment and CsDocCommentRawComment were handled. Convert structured doc comments back to their raw textual form before sending so the receiver can reconstruct them on demand. Also bumps Microsoft.CodeAnalysis.* packages from 5.0.0 to 5.3.0.
jkschneider
requested changes
Jun 3, 2026
Address review feedback: instead of flattening a structured CsDocComment.DocComment back to raw text in the sender, add a proper doc-comment tree visitor (CsDocCommentSender/CsDocCommentReceiver) that decomposes and reconstructs the tree over RPC, mirroring how the Java side handles Javadoc.DocComment. The comment is now keyed by its id in Space's comment list and each node sends its id, markers, and fields. The C# side has no structured doc-comment model (it stores raw XmlDocComment text), so CsDocCommentReceiver.cs consumes the decomposed tree and re-flattens it to text, exactly mirroring CsDocCommentPrinter. Without this the C# receiver threw when a recipe-modified tree containing a structured doc comment was serialized back for printing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CSharpVisitorpass parses a rawCsDocCommentRawCommentinto a structuredCsDocComment.DocCommenttree. Previously the RPC sender flattened that tree back to raw text; this PR instead adds a proper doc-comment tree visitor pair (CsDocCommentSender/CsDocCommentReceiver) that decomposes and reconstructs the tree over RPC, mirroring how the Java side keysJavadoc.DocCommentby id. The comment is now keyed by its id inSpace's comment list and each node transmits its id, markers, and fields (including embeddedJcref/name references).XmlDocCommenttext), soCsDocCommentReceiver.csconsumes the decomposed tree and re-flattens it to text, mirroringCsDocCommentPrinter. Without this the C# receiver threwCannot map Java type name: CsDocComment$DocCommentwhen a recipe-modified tree was serialized back for printing.Microsoft.CodeAnalysis.*packages from 5.0.0 to 5.3.0.Test plan
CSharpSenderDocCommentTest, including a multiline/nested-element case.CSharpRecipeTestthat forces structuring via aCSharpVisitorpass thenprint()s through the real C# RPC process (the path that previously crashed).rewrite-csharpJava suite passes; all 1945 C# xUnit tests pass.