Skip to content

C#: decompose CsDocComment.DocComment over RPC via a proper visitor#7894

Merged
macsux merged 2 commits into
mainfrom
macsux/csdoccomment-history
Jun 3, 2026
Merged

C#: decompose CsDocComment.DocComment over RPC via a proper visitor#7894
macsux merged 2 commits into
mainfrom
macsux/csdoccomment-history

Conversation

@macsux

@macsux macsux commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A CSharpVisitor pass parses a raw CsDocCommentRawComment into a structured CsDocComment.DocComment tree. 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 keys Javadoc.DocComment by id. The comment is now keyed by its id in Space's comment list and each node transmits its id, markers, and fields (including embedded J cref/name references).
  • 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, mirroring CsDocCommentPrinter. Without this the C# receiver threw Cannot map Java type name: CsDocComment$DocComment when a recipe-modified tree was serialized back for printing.
  • Also bumps Microsoft.CodeAnalysis.* packages from 5.0.0 to 5.3.0.

Test plan

  • New Java sender→receiver round-trip tests in CSharpSenderDocCommentTest, including a multiline/nested-element case.
  • New end-to-end regression test in CSharpRecipeTest that forces structuring via a CSharpVisitor pass then print()s through the real C# RPC process (the path that previously crashed).
  • Full rewrite-csharp Java suite passes; all 1945 C# xUnit tests pass.

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.
Comment thread rewrite-csharp/src/main/java/org/openrewrite/csharp/rpc/CSharpSender.java Outdated
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.
@macsux macsux changed the title C#: flatten CsDocComment.DocComment to raw form in RPC sender C#: decompose CsDocComment.DocComment over RPC via a proper visitor Jun 3, 2026
@macsux macsux merged commit 023385d into main Jun 3, 2026
1 check passed
@macsux macsux deleted the macsux/csdoccomment-history branch June 3, 2026 21:00
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants