Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 6, 2025

Summary

This PR fixes issue #6770 where C# code with generic types was being incorrectly modified when using the write_to_file tool with non-Claude models.

Problem

The write_to_file tool was calling unescapeHtmlEntities() on content for non-Claude models, which was converting angle brackets in C# generic types (like Configure<BlazorServerSettings>) into HTML entities (Configure<BlazorServerSettings>).

Solution

  • Removed the unescapeHtmlEntities() call from writeToFileTool.ts that was being applied to non-Claude models
  • This ensures that C# generics and other code with angle brackets are preserved exactly as written

Changes

  • Removed HTML entity unescaping logic from src/core/tools/writeToFileTool.ts
  • Updated tests in src/core/tools/__tests__/writeToFileTool.spec.ts to verify C# generics are preserved correctly
  • Added new test cases to ensure angle brackets and HTML entities are handled properly

Testing

  • All existing tests pass ✅
  • Added specific test cases for C# generics preservation
  • Verified that angle brackets in code are no longer converted to HTML entities

Fixes #6770


Important

Fixes issue with write_to_file tool by removing HTML entity conversion to preserve C# generics and angle brackets.

  • Behavior:
    • Removed unescapeHtmlEntities() call from writeToFileTool.ts to preserve C# generics and angle brackets.
    • Ensures content is written as-is without HTML entity conversion.
  • Testing:
    • Updated writeToFileTool.spec.ts to include tests for C# generics and HTML entity preservation.
    • Added test cases to verify angle brackets and HTML entities are handled correctly.
  • Misc:
    • Removed mock for unescapeHtmlEntities in writeToFileTool.spec.ts.

This description was created by Ellipsis for fe9811d. You can customize this summary. It will automatically update as commits are pushed.

…C# generics

- Removed unescapeHtmlEntities call that was converting angle brackets in C# generic types
- This fixes issue #6770 where C# code like Configure<BlazorServerSettings> was being incorrectly converted to Configure<BlazorServerSettings>
- Updated tests to verify C# generics and angle brackets are preserved correctly
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 6, 2025 21:09
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 6, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.

newContent = unescapeHtmlEntities(newContent)
}

// Determine if the path is outside the workspace
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good fix removing the HTML entity unescaping. However, I noticed that applyDiffTool.ts (line 29) and multiApplyDiffTool.ts (line 418) still use unescapeHtmlEntities() for non-Claude models. Should we remove it from those tools as well for consistency? This could affect users working with C# or other languages with angle brackets across different tools.


it("skips HTML unescaping for Claude models", async () => {
mockCline.api.getModel.mockReturnValue({ id: "claude-3" })
it("preserves HTML entities in content without unescaping", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These test cases for C# generics and HTML entities look good. Consider adding a test case for mixed content (e.g., actual HTML with entities alongside C# code) to ensure we're not breaking legitimate HTML entity usage in edge cases?

}

// Determine if the path is outside the workspace
const fullPath = relPath ? path.resolve(cline.cwd, removeClosingTag("path", relPath)) : ""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider adding a comment here explaining why we don't unescape HTML entities (to preserve code exactly as written, especially for languages like C# with generics). This would help prevent future developers from re-introducing this logic thinking it was an oversight.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 6, 2025
@daniel-lxs
Copy link
Member

Closing, see discussion on #4077

@daniel-lxs daniel-lxs closed this Aug 7, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 7, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

C# code gets changed wrongly because of syntax-problems

4 participants