-
-
Notifications
You must be signed in to change notification settings - Fork 63
Add Unicode support for XML doc comment generation #948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
390ee8c
Fix Unicode XML status code comments
christianhelle 608eb08
Update squad records for issue 944
christianhelle 46b5bcd
Clarify cross-platform paths in TUnit skill documentation
christianhelle 204103b
Update squad history and decision records
christianhelle 3414c6c
Improve XML documentation generation for unicode and invalid characters
christianhelle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| --- | ||
| updated_at: 2026-03-02T15:49:46Z | ||
| focus_area: Post-review backlog — bugs, tests, CI fixes | ||
| active_issues: [] | ||
| updated_at: 2026-03-06T16:09:05.259Z | ||
| focus_area: Issue #944 implementation and validation | ||
| active_issues: | ||
| - 944 | ||
| --- | ||
|
|
||
| # What We're Focused On | ||
|
|
||
| Full codebase review completed (2026-03-02). Keaton, Fenster, Hockney, McManus all ran. Findings are in `.squad/decisions.md` and `.squad/identity/backlog.md`. | ||
|
|
||
| Next session: pick from the backlog in priority order. Start with the security fix (Codecov token), then the bug trio (GetInterfaceName, ContractsOutputFolder, ParameterExtractor mutation), then test gaps. | ||
| Implementing and validating the fix for issue #944. The patch is in `src\Refitter.Core\XmlDocumentationGenerator.cs` with regression coverage in `src\Refitter.Tests\XmlDocumentationGeneratorTests.cs` and `src\Refitter.Tests\Examples\GenerateStatusCodeCommentsTests.cs`; full PR-gate validation is now running. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Fenster — Issue #944 Orchestration Log — 2026-03-06T16-29-27Z | ||
|
|
||
| ## Task: Implement production fix for non-ASCII XML documentation | ||
|
|
||
| **Outcome:** ✅ COMPLETE | ||
|
|
||
| Fixed `src/Refitter.Core/XmlDocumentationGenerator.cs` to decode JSON-style escaped Unicode sequences (`\uXXXX`) from NSwag response descriptions before XML-escaping. The `DecodeJsonEscapedText()` method safely handles: | ||
| - `\uXXXX` four-hex-digit Unicode escape sequences | ||
| - `\"` escaped quotes | ||
| - `\\` escaped backslashes | ||
| - `\n`, `\r`, `\t` whitespace escapes | ||
| - Preserves hardcoded XML markup (`<see cref="..."/>`, `<list>`, etc.) | ||
| - XML-escapes `&`, `<`, `>` in user text after decoding | ||
|
|
||
| **Files Modified:** | ||
| - `src/Refitter.Core/XmlDocumentationGenerator.cs` — added `DecodeJsonEscapedText()` helper and applied to `BuildResponseDescription()` method | ||
|
|
||
| **Build Status:** Passed | ||
| **Test Status:** Targeted tests passed | ||
| **Gates:** Build ✅ | Tests ✅ | Format ✅ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Hockney — Issue #944 Orchestration Log — 2026-03-06T16-29-27Z | ||
|
|
||
| ## Task: Add regression coverage for non-ASCII XML documentation fix | ||
|
|
||
| **Outcome:** ✅ COMPLETE | ||
|
|
||
| Added comprehensive regression test coverage at two levels: | ||
|
|
||
| 1. **Unit Tests** — `src/Refitter.Tests/XmlDocumentationGeneratorTests.cs` | ||
| - Direct assertion on `XmlDocumentationGenerator.BuildResponseDescription()` | ||
| - Validates that readable Unicode (Cyrillic example: `Возврат`) is preserved in XML output | ||
| - Verifies that `\uXXXX` escape sequences are decoded, not emitted raw | ||
|
|
||
| 2. **Integration Tests** — `src/Refitter.Tests/Examples/GenerateStatusCodeCommentsTests.cs` | ||
| - End-to-end test: inline OpenAPI spec → full generator pipeline → C# code generation | ||
| - Verifies generated code compiles successfully via `BuildHelper.BuildCSharp()` | ||
| - Protects against regressions in the full compilation workflow | ||
|
|
||
| **Files Modified:** | ||
| - `src/Refitter.Tests/XmlDocumentationGeneratorTests.cs` — new unit tests | ||
| - `src/Refitter.Tests/Examples/GenerateStatusCodeCommentsTests.cs` — new integration tests | ||
|
|
||
| **Test Results:** All targeted tests passed | ||
| **Scope:** Narrow, focused coverage; no production code touched in test project |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Keaton — Issue #944 Orchestration Log — 2026-03-06T16-29-27Z | ||
|
|
||
| ## Task: Review and validate Issue #944 patch | ||
|
|
||
| **Outcome:** ✅ APPROVED | ||
|
|
||
| Conducted thorough review of the non-ASCII XML documentation fix. Validated: | ||
|
|
||
| **Correctness:** | ||
| - Root cause correctly identified: NSwag's `ConversionUtilities.ConvertToStringLiteral()` encodes non-ASCII as `\uXXXX` escape sequences | ||
| - Fix location is precise: only `ExceptionDescription` uses this encoding; other NSwag fields (Summary, Description) are raw strings | ||
| - Decode-then-XML-escape ordering prevents injection attacks on decoded `<`, `>`, `&` characters | ||
| - Bounds checking on `\uXXXX` parsing is correct: `index + 4 < input.Length` | ||
| - Surrogate pairs handled correctly via C# UTF-16 char semantics | ||
| - Fast-path optimization for ASCII-only strings (early return if no backslashes) | ||
|
|
||
| **Testing:** | ||
| - Unit test: readable Cyrillic assertion validates decoding | ||
| - Integration test: compilation verification of generated code | ||
| - All 1415 tests pass; no regressions | ||
|
|
||
| **Gates:** Build ✅ | Tests ✅ (1415/1415) | Format ✅ | ||
|
|
||
| **Files Affected:** | ||
| - `src/Refitter.Core/XmlDocumentationGenerator.cs` | ||
| - `src/Refitter.Tests/XmlDocumentationGeneratorTests.cs` | ||
| - `src/Refitter.Tests/Examples/GenerateStatusCodeCommentsTests.cs` | ||
|
|
||
| **Recommendation:** READY FOR MERGE |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --- | ||
| name: "tunit-test-filtering" | ||
| description: "Run focused Refitter tests with TUnit treenode filters" | ||
| domain: "testing" | ||
| confidence: "high" | ||
| source: "manual" | ||
| --- | ||
|
|
||
| ## Context | ||
| Refitter test projects use TUnit on Microsoft.Testing.Platform. In this repo, `dotnet test --filter ...` is not supported by the compiled test application, so the fastest reliable way to run a tiny subset of tests is through the generated test executable and a tree-node filter. | ||
|
|
||
| ## Pattern | ||
|
|
||
| ### Use the compiled test executable | ||
| - Test app path: `src\Refitter.Tests\bin\Release\net10.0\Refitter.Tests.exe` | ||
| - Note: The examples use Windows-style backslashes (`\`). On Linux/macOS or in bash/zsh, use forward slashes (`/`), e.g., `src/Refitter.Tests/bin/Release/net10.0/Refitter.Tests.exe`. | ||
| - Source-generator test discovery means you should build the test project first if you added or renamed tests. | ||
|
|
||
| ### Tree filter syntax | ||
| - Format: `/*/<Namespace>/<Class>/<Test>` | ||
| - Example: | ||
|
|
||
| ```powershell | ||
| & 'src\Refitter.Tests\bin\Release\net10.0\Refitter.Tests.exe' ` | ||
| --treenode-filter '/*/Refitter.Tests.Examples/GenerateStatusCodeCommentsTests/Generated_Code_With_Unicode_Status_Code_Comments_Can_Build' ` | ||
| --disable-logo ` | ||
| --no-progress | ||
| ``` | ||
|
|
||
| ### Verified repo-specific examples | ||
| - `/*/Refitter.Tests/XmlDocumentationGeneratorTests/Can_Generate_Method_Throws_With_Readable_Unicode_Status_Code_Comments` | ||
| - `/*/Refitter.Tests.Examples/GenerateStatusCodeCommentsTests/Generated_Code_Preserves_Readable_Unicode_In_Status_Code_Comments` | ||
| - `/*/Refitter.Tests.Examples/GenerateStatusCodeCommentsTests/Generated_Code_With_Unicode_Status_Code_Comments_Can_Build` | ||
|
|
||
| ## Anti-Patterns | ||
| - Do **not** rely on `dotnet test --filter ...` here; the TUnit/Microsoft.Testing.Platform test app rejects that option. | ||
| - Do **not** assume OR expressions are necessary for a tiny run; separate single-test invocations are often simpler and more reliable. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| name: "xml-doc-description-sanitization" | ||
| description: "Preserve readable Unicode when copying OpenAPI response descriptions into XML doc comments" | ||
| domain: "code-generation" | ||
| confidence: "high" | ||
| source: "manual" | ||
| --- | ||
|
|
||
| ## Context | ||
| `src\Refitter.Core\XmlDocumentationGenerator.cs` writes OpenAPI response descriptions into generated XML documentation comments. Those descriptions may arrive from NSwag in JSON-escaped form (`\uXXXX`, `\"`, `\n`) even though the source OpenAPI file already contains readable Unicode. | ||
|
|
||
| ## Pattern | ||
|
|
||
| ### Sanitize user-sourced response descriptions only | ||
| - Decode JSON-style escape sequences before writing the text into XML docs. | ||
| - After decoding, escape XML-reserved characters (`&`, `<`, `>`) so the generated comments remain valid XML. | ||
| - Apply this only to OpenAPI-sourced response description text such as `method.ResultDescription` and `response.ExceptionDescription`. | ||
|
|
||
| ### Preserve intentional XML doc markup | ||
| - Do **not** run the same sanitization over hardcoded fallback strings that intentionally contain `<see cref="..."/>`, `<list>`, or other XML doc tags. | ||
| - Sanitize at the insertion point where raw API text enters the XML comment output. | ||
|
|
||
| ## Example | ||
|
|
||
| ```csharp | ||
| var description = this.EscapeSymbols(this.DecodeJsonEscapedText(responseDescription)); | ||
| ``` | ||
|
|
||
| ## Anti-Patterns | ||
| - Appending `method.ResultDescription` or `response.ExceptionDescription` directly into XML comments. | ||
| - XML-escaping entire doc fragments that intentionally contain XML doc markup. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.