fix(csharp): decode HTML entities in XML documentation comments#10412
Merged
fern-support merged 4 commits intomainfrom Nov 10, 2025
Merged
fix(csharp): decode HTML entities in XML documentation comments#10412fern-support merged 4 commits intomainfrom
fern-support merged 4 commits intomainfrom
Conversation
Fixes bug where HTML entities like +, −, ×, etc. in API descriptions were being copied directly into C# XML documentation comments, causing compilation errors. XML only recognizes 5 predefined entities (<, >, &, ", '), so other HTML entities are invalid. The fix decodes HTML entities to their actual Unicode characters before writing them to XML documentation, preventing invalid XML entity errors while preserving valid XML entities. Added test fixture csharp-xml-entities to verify the fix works correctly. Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
dsinghvi
approved these changes
Nov 10, 2025
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.
Description
Fixes bug where HTML entities in API documentation were causing C# compilation errors.
Link to Devin run: https://app.devin.ai/sessions/6ac5baab8cd14fc28a0a95bc894527f5
Requested by: judah@buildwithfern.com (@jsklan)
Problem
When OpenAPI specs or Fern definitions contained HTML entities like
+,−,×, etc. in documentation strings, the C# generator copied them directly into XML documentation comments. Since C# XML only recognizes 5 predefined entities (<,>,&,",'), this caused compilation errors:This affected real-world SDKs like the Square .NET SDK, blocking CI builds and preventing PR merges.
Solution
Added
decodeHtmlEntities()method toXmlDocWriterthat:+→+,×→×) → space, → space)Example transformation:
Changes Made
generators/csharp/codegen/src/ast/core/XmlDocWriter.ts:decodeHtmlEntities()method with comprehensive entity mappingescapeXmlDocContent()pipelinecsharp-xml-entitiesto verify the fixTesting
csharp-xml-entitiesfixture+,−,×,÷, ,…,·,©) are decoded to Unicode<,>,&) are preserved correctlyReview Focus
Critical to verify:
seed/csharp-sdk/csharp-xml-entities/no-custom-config/src/SeedCsharpXmlEntities/Types/TimeZoneModel.csto see the entities properly decoded in the final output.Performance note: The implementation uses
replaceAllfor each entity in a loop. For typical documentation strings this is negligible, but it's worth noting for very large doc strings.