From 183579568c6b5003a65104c6eb18cd98b113ab6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 6 Aug 2024 14:09:20 -0700
Subject: [PATCH 1/4] Replace code-data-dev-comment-type elements with the
correct one.
---
src/PortToDocs/src/libraries/XmlHelper.cs | 2 +
.../tests/PortToDocs.Strings.Tests.cs | 60 +++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/src/PortToDocs/src/libraries/XmlHelper.cs b/src/PortToDocs/src/libraries/XmlHelper.cs
index 8a5cb69..83aba66 100644
--- a/src/PortToDocs/src/libraries/XmlHelper.cs
+++ b/src/PortToDocs/src/libraries/XmlHelper.cs
@@ -61,6 +61,7 @@ internal class XmlHelper
{ @"\<(see|seealso){1} cref\=""object""[ ]*\/\>", "" },
{ @"\<(see|seealso){1} cref\=""dynamic""[ ]*\/\>", "" },
{ @"\<(see|seealso){1} cref\=""string""[ ]*\/\>", "" },
+ { "[a-zA-Z0-9_]+)\">(?[a-zA-Z0-9_]+)
", "" },
};
private static readonly Dictionary _replaceableMarkdownPatterns = new Dictionary {
@@ -120,6 +121,7 @@ internal class XmlHelper
// Params, typeparams, langwords
{ @"\<(typeparamref|paramref){1} name\=""(?'refNameContents'[a-zA-Z0-9_\-]+)""[ ]*\/\>", @"`${refNameContents}`" },
{ @"\", @"`${seeLangwordContents}`" },
+ { "(?[a-zA-Z0-9_]+)
", "`${elementValue}`" },
};
private static readonly string[] _splittingSeparators = new string[] { "\r", "\n", "\r\n" };
diff --git a/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs b/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
index d0b9df3..dca6b2b 100644
--- a/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
+++ b/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
@@ -2466,6 +2466,66 @@ I am paragraph number three.
TestWithStrings(originalIntellisense, originalDocs, expectedDocs, configuration);
}
+ [Fact]
+ public void Convert_DataDevCommentType_To_ExpectedElementNames()
+ {
+ // The compiled xml files sometimes generate langwords, paramrefs and typeparamrefs with the format
+ // ...
, so we need to convert them to the expected element type.
+
+ string originalIntellisense = @"
+
+
+ MyAssembly
+
+
+
+ Langword true
. Paramref myParam
. Typeparamref myTypeParam
.
+ Langword true
. Paramref myParam
. Typeparamref myTypeParam
.
+
+
+";
+
+ string originalDocs = @"
+
+
+ MyAssembly
+
+
+ To be added.
+ To be added.
+
+
+";
+
+ string expectedDocs = @"
+
+
+ MyAssembly
+
+
+ Langword . Paramref . Typeparamref .
+
+
+
+
+
+";
+
+ Configuration configuration = new()
+ {
+ MarkdownRemarks = true
+ };
+ configuration.IncludedAssemblies.Add(FileTestData.TestAssembly);
+
+ TestWithStrings(originalIntellisense, originalDocs, expectedDocs, configuration);
+ }
+
private static void TestWithStrings(string intellisenseFile, string originalDocsFile, string expectedDocsFile, Configuration configuration) =>
TestWithStrings(intellisenseFile, new List() { new StringTestData(originalDocsFile, expectedDocsFile) }, configuration);
From 284ed7ea41e62126638186cea2a3eaca3c0eec5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 6 Aug 2024 15:01:48 -0700
Subject: [PATCH 2/4] Fix xref data-throw-if-not-resolved too
---
src/PortToDocs/src/libraries/XmlHelper.cs | 6 +-
.../tests/PortToDocs.Strings.Tests.cs | 62 ++++++++++++++++++-
2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/src/PortToDocs/src/libraries/XmlHelper.cs b/src/PortToDocs/src/libraries/XmlHelper.cs
index 83aba66..c3b66b6 100644
--- a/src/PortToDocs/src/libraries/XmlHelper.cs
+++ b/src/PortToDocs/src/libraries/XmlHelper.cs
@@ -61,7 +61,8 @@ internal class XmlHelper
{ @"\<(see|seealso){1} cref\=""object""[ ]*\/\>", "" },
{ @"\<(see|seealso){1} cref\=""dynamic""[ ]*\/\>", "" },
{ @"\<(see|seealso){1} cref\=""string""[ ]*\/\>", "" },
- { "[a-zA-Z0-9_]+)\">(?[a-zA-Z0-9_]+)
", "" },
+ { @"[a-zA-Z0-9_]+)"">(?[a-zA-Z0-9_]+)
", "" },
+ { @".+)""><\/xref>", "" },
};
private static readonly Dictionary _replaceableMarkdownPatterns = new Dictionary {
@@ -121,7 +122,8 @@ internal class XmlHelper
// Params, typeparams, langwords
{ @"\<(typeparamref|paramref){1} name\=""(?'refNameContents'[a-zA-Z0-9_\-]+)""[ ]*\/\>", @"`${refNameContents}`" },
{ @"\", @"`${seeLangwordContents}`" },
- { "(?[a-zA-Z0-9_]+)
", "`${elementValue}`" },
+ { @"(?[a-zA-Z0-9_]+)
", "`${elementValue}`" },
+ { @".+)""><\/xref>", "" },
};
private static readonly string[] _splittingSeparators = new string[] { "\r", "\n", "\r\n" };
diff --git a/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs b/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
index dca6b2b..0ccd9b0 100644
--- a/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
+++ b/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
@@ -2467,7 +2467,7 @@ I am paragraph number three.
}
[Fact]
- public void Convert_DataDevCommentType_To_ExpectedElementNames()
+ public void Convert_CodeDataDevCommentType_To_ExpectedElementNames()
{
// The compiled xml files sometimes generate langwords, paramrefs and typeparamrefs with the format
// ...
, so we need to convert them to the expected element type.
@@ -2526,6 +2526,66 @@ public void Convert_DataDevCommentType_To_ExpectedElementNames()
TestWithStrings(originalIntellisense, originalDocs, expectedDocs, configuration);
}
+ [Fact]
+ public void Convert_XrefDataThrowIfNotResolved_To_ExpectedElementNames()
+ {
+ // The compiled xml files sometimes generate type references with the format
+ // , so we need to convert them to the expected element type.
+
+ string originalIntellisense = @"
+
+
+ MyAssembly
+
+
+
+ Type: .
+ Type: .
+
+
+";
+
+ string originalDocs = @"
+
+
+ MyAssembly
+
+
+ To be added.
+ To be added.
+
+
+";
+
+ string expectedDocs = @"
+
+
+ MyAssembly
+
+
+ Type: .
+
+ .
+
+ ]]>
+
+
+
+";
+
+ Configuration configuration = new()
+ {
+ MarkdownRemarks = true
+ };
+ configuration.IncludedAssemblies.Add(FileTestData.TestAssembly);
+
+ TestWithStrings(originalIntellisense, originalDocs, expectedDocs, configuration);
+ }
+
private static void TestWithStrings(string intellisenseFile, string originalDocsFile, string expectedDocsFile, Configuration configuration) =>
TestWithStrings(intellisenseFile, new List() { new StringTestData(originalDocsFile, expectedDocsFile) }, configuration);
From 81f28009ce5c070844c7972a6fb0012b0ce05fc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 6 Aug 2024 15:15:15 -0700
Subject: [PATCH 3/4] Better regex pattern
---
src/PortToDocs/src/libraries/XmlHelper.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PortToDocs/src/libraries/XmlHelper.cs b/src/PortToDocs/src/libraries/XmlHelper.cs
index c3b66b6..733cc8e 100644
--- a/src/PortToDocs/src/libraries/XmlHelper.cs
+++ b/src/PortToDocs/src/libraries/XmlHelper.cs
@@ -62,7 +62,7 @@ internal class XmlHelper
{ @"\<(see|seealso){1} cref\=""dynamic""[ ]*\/\>", "" },
{ @"\<(see|seealso){1} cref\=""string""[ ]*\/\>", "" },
{ @"[a-zA-Z0-9_]+)"">(?[a-zA-Z0-9_]+)
", "" },
- { @".+)""><\/xref>", "" },
+ { @"[a-zA-Z0-9_,\<\>\.\@\#\$%^&`\(\)]+)""><\/xref>", "" },
};
private static readonly Dictionary _replaceableMarkdownPatterns = new Dictionary {
@@ -123,7 +123,7 @@ internal class XmlHelper
{ @"\<(typeparamref|paramref){1} name\=""(?'refNameContents'[a-zA-Z0-9_\-]+)""[ ]*\/\>", @"`${refNameContents}`" },
{ @"\", @"`${seeLangwordContents}`" },
{ @"(?[a-zA-Z0-9_]+)
", "`${elementValue}`" },
- { @".+)""><\/xref>", "" },
+ { @"[a-zA-Z0-9_,\<\>\.]+)""><\/xref>", "" },
};
private static readonly string[] _splittingSeparators = new string[] { "\r", "\n", "\r\n" };
From fee74406809320cc84a61d24070b2c8af380d400 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 6 Aug 2024 15:20:35 -0700
Subject: [PATCH 4/4] Even better regex
---
src/PortToDocs/tests/PortToDocs.Strings.Tests.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs b/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
index 0ccd9b0..5b56cc7 100644
--- a/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
+++ b/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
@@ -2539,7 +2539,7 @@ public void Convert_XrefDataThrowIfNotResolved_To_ExpectedElementNames()
- Type: .
+ Type: .
Type: .