diff --git a/src/PortToDocs/src/libraries/XmlHelper.cs b/src/PortToDocs/src/libraries/XmlHelper.cs index 8a5cb69..733cc8e 100644 --- a/src/PortToDocs/src/libraries/XmlHelper.cs +++ b/src/PortToDocs/src/libraries/XmlHelper.cs @@ -61,6 +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_,\<\>\.\@\#\$%^&`\(\)]+)""><\/xref>", "" }, }; private static readonly Dictionary _replaceableMarkdownPatterns = new Dictionary { @@ -120,6 +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_,\<\>\.]+)""><\/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 d0b9df3..5b56cc7 100644 --- a/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs +++ b/src/PortToDocs/tests/PortToDocs.Strings.Tests.cs @@ -2466,6 +2466,126 @@ I am paragraph number three. TestWithStrings(originalIntellisense, originalDocs, expectedDocs, configuration); } + [Fact] + 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. + + 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); + } + + [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);