Fix HTML escaping for generic type parameters in reports #39
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.
Problem
HTML reports were breaking when displaying API signatures containing generic type parameters. For example, signatures like
ICollection<object>were being interpreted by browsers as HTML<object>tags instead of being displayed as intended C# code.This caused the HTML structure to become malformed and prevented proper rendering of the reports.
Solution
HtmlEscapemethod: Properly encodes special HTML characters (&,<,>,",') to their HTML entity equivalentsGroupChangesmethod: Applied HTML escaping to bothold_signatureandnew_signaturevalues before template renderingChanges
Modified Files
src/DotNetApiDiff/Reporting/HtmlFormatterScriban.csHtmlEscapestatic method with comprehensive character encodingGroupChangesto escape HTML entitiestests/DotNetApiDiff.Tests/Reporting/HtmlFormatterScribanTests.csFormat_WithGenericTypeSignatures_ProperlyEscapesHtmltest methodICollection<object>toICollection<object>Testing
The fix has been validated with:
Impact
ICollection<object>broke HTML structureICollection<object>in browsersThis fix ensures that all API signatures with generic type parameters are properly displayed in HTML reports without breaking the document structure.