diff --git a/samples/seed/dotnet/project/Project/Inheritdoc.cs b/samples/seed/dotnet/project/Project/Inheritdoc.cs index a2423174f30..be73e56bf7f 100644 --- a/samples/seed/dotnet/project/Project/Inheritdoc.cs +++ b/samples/seed/dotnet/project/Project/Inheritdoc.cs @@ -108,4 +108,41 @@ public class Class2 : Class1 public override bool TestMethod1(bool parm1, int parm2) => false; } } -} \ No newline at end of file + + // Issue #9736 #9495 #9754 + public class Issue9736 + { + public interface IJsonApiOptions + { + /// + /// Whether to use relative links for all resources. false by default. + /// + /// + /// + /// + /// + bool UseRelativeLinks { get; } + } + + public sealed class JsonApiOptions : IJsonApiOptions + { + /// + public bool UseRelativeLinks { get; set; } + } + } +} diff --git a/src/Docfx.Dotnet/Parsers/XmlComment.cs b/src/Docfx.Dotnet/Parsers/XmlComment.cs index da4467e3fcc..b38a123025c 100644 --- a/src/Docfx.Dotnet/Parsers/XmlComment.cs +++ b/src/Docfx.Dotnet/Parsers/XmlComment.cs @@ -121,10 +121,6 @@ public static XmlComment Parse(string xml, XmlCommentParserContext context = nul } try { - // Format xml with indentation. - // It's needed to fix issue (https://github.com/dotnet/docfx/issues/9736) - xml = XElement.Parse(xml).ToString(SaveOptions.None); - return new XmlComment(xml, context ?? new()); } catch (XmlException) @@ -170,7 +166,8 @@ private void ResolveCode(XDocument doc, XmlCommentParserContext context) code.SetAttributeValue("class", $"lang-{lang}"); - if (node.PreviousNode is null) + if (node.PreviousNode is null + || node.PreviousNode is XText xText && xText.Value == $"\n{indent}") { // Xml writer formats
 with unintended identation
                 // when there is no preceeding text node.
diff --git a/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs b/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs
index 0a2035f3daf..9906c514222 100644
--- a/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs
+++ b/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs
@@ -28,7 +28,8 @@ public static void ParaNewLine()
         Assert.Equal(
             """
             a
-            

b

c

+

b

+

c

""", XmlComment.Parse(""" @@ -390,13 +391,14 @@ Classes in assemblies are by definition complete. example

This is ref a sample of exception node

  • -
    public class XmlElement
    -                      : XmlLinkedNode
    -
    1. - word inside list->listItem->list->listItem->para.> + +
      public class XmlElement
      +                            : XmlLinkedNode
      +
      1. + word inside list->listItem->list->listItem->para.> the second line.
      2. item2 in numbered list
      -
    2. item2 in bullet list
    3. +
    4. item2 in bullet list
    5. loose text not wrapped in description
""", remarks, ignoreLineEndingDifferences: true); @@ -519,6 +521,7 @@ public void Issue9495() Assert.Equal( """
options.UseRelativeLinks = true;
+
{
               "type": "articles",
               "id": "4309",
@@ -533,4 +536,45 @@ public void Issue9495()
             }
""", comment.Examples[0], ignoreLineEndingDifferences: true); } + + [Fact] + public void Issue10385() + { + var comment = XmlComment.Parse( + """ + + + Paragraph. + + + public sealed class Issue10385 + { + public int AAA {get;set;} + + public int BBB {get;set;} + + public int CCC {get;set;} + } + + + """); + Assert.Equal( + """ +

+ Paragraph. +

+ +
public sealed class Issue10385
+            {
+                public int AAA {get;set;}
+
+                public int BBB {get;set;}
+
+                public int CCC {get;set;}
+            }
+ """, comment.Remarks, ignoreLineEndingDifferences: true); + } + + + }