-
Notifications
You must be signed in to change notification settings - Fork 884
Description
Describe the bug
When using /// <inheritdoc /> on a class property that implements an interface, its example code is escaped twice, resulting in broken HTML.
To Reproduce
Steps to reproduce the behavior:
- Download the zip file below, which contains a minimal repro project
DocfxEscapeBugRepro.zip - Run
dotnet tool restore - Run
dotnet docfx docs/docfx.json --serve - Open
http://localhost:8080in your browser - Click API > IJsonApiOptions
- Observe the example HTML is rendered properly

- Click JsonApiOptions
- Observe the example HTML is broken

Expected behavior
Example code is rendered properly on both pages.
Context (please complete the following information):
- OS: Windows 11
- Docfx version: 2.75.3
- .NET version: .NET 8
docfx.jsonconfig: as produced bydotnet docfx init, see zip file- Exceptions: none
- Errors and warnings: none
- .NET info:
.NET SDK:
Version: 8.0.201
Commit: 4c2d78f037
Workload version: 8.0.200-manifests.e575128c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.201\
.NET workloads installed:
There are no installed workloads to display.
Host:
Version: 8.0.2
Architecture: x64
Commit: 1381d5ebd2
.NET SDKs installed:
8.0.200 [C:\Program Files\dotnet\sdk]
8.0.201 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Additional context
I've been debugging through the docfx sources and found that since v2.74.1 (which introduced this bug), Docfx.Dotnet.XmlComment.ResolveCode() was changed to wrap <code> into a <pre> node. I suspect this isn't the right place to do that, because it seems that mustache applies escaping as well, though I'm not entirely sure where that happens. I haven't been able to trace exactly where the double escaping originates from.
Any pointers to investigate further would be appreciated.