Skip to content

Commit

Permalink
Fix bug in code data-dev-comment conversions.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossanlop committed Aug 7, 2024
1 parent 1cc3a53 commit dea5237
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/PortToDocs/src/libraries/XmlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ internal class XmlHelper
{ @"\<(see|seealso){1} cref\=""object""[ ]*\/\>", "<see cref=\"T:System.Object\" />" },
{ @"\<(see|seealso){1} cref\=""dynamic""[ ]*\/\>", "<see langword=\"dynamic\" />" },
{ @"\<(see|seealso){1} cref\=""string""[ ]*\/\>", "<see cref=\"T:System.String\" />" },
{ @"<code data-dev-comment-type=""(?<elementName>[a-zA-Z0-9_]+)"">(?<elementValue>[a-zA-Z0-9_]+)</code>", "<see ${elementName}=\"${elementValue}\" />" },
{ @"<xref data-throw-if-not-resolved=""[a-zA-Z0-9_]+"" uid=""(?<docId>[a-zA-Z0-9_,\<\>\.\@\#\$%^&`\(\)]+)""><\/xref>", "<see cref=\"T:${docId}\" />" },
{ @"<code data-dev-comment-type=""langword"">(?<elementValue>[a-zA-Z0-9_]+)</code>", "<see langword=\"${elementValue}\" />" },
{ @"<code data-dev-comment-type=""paramref"">(?<elementValue>[a-zA-Z0-9_]+)</code>", "<paramref name=\"${elementValue}\" />" },
{ @"<code data-dev-comment-type=""typeparamref"">(?<elementValue>[a-zA-Z0-9_]+)</code>", "<typeparamref name=\"${elementValue}\" />" },
{ @"<xref data-throw-if-not-resolved=""[a-zA-Z0-9_]+"" uid=""(?<docId>[a-zA-Z0-9_,\<\>\.\@\#\$%^&`\(\)]+)""(><\/xref>|[ ]*/>)", "<see cref=\"T:${docId}\" />" },
};

private static readonly Dictionary<string, string> _replaceableMarkdownPatterns = new Dictionary<string, string> {
Expand Down Expand Up @@ -123,7 +125,7 @@ internal class XmlHelper
{ @"\<(typeparamref|paramref){1} name\=""(?'refNameContents'[a-zA-Z0-9_\-]+)""[ ]*\/\>", @"`${refNameContents}`" },
{ @"\<see langword\=""(?'seeLangwordContents'[a-zA-Z0-9_\-]+)""[ ]*\/\>", @"`${seeLangwordContents}`" },
{ @"<code data-dev-comment-type=""[a-zA-Z0-9_]+"">(?<elementValue>[a-zA-Z0-9_]+)</code>", "`${elementValue}`" },
{ @"<xref data-throw-if-not-resolved=""[a-zA-Z0-9_]+"" uid=""(?<docId>[a-zA-Z0-9_,\<\>\.]+)""><\/xref>", "<xref:${docId}>" },
{ @"<xref data-throw-if-not-resolved=""[a-zA-Z0-9_]+"" uid=""(?<docId>[a-zA-Z0-9_,\<\>\.]+)""(><\/xref>|[ ]*/>)", "<xref:${docId}>" },
};

private static readonly string[] _splittingSeparators = new string[] { "\r", "\n", "\r\n" };
Expand Down
2 changes: 1 addition & 1 deletion src/PortToDocs/tests/PortToDocs.Strings.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,7 @@ public void Convert_CodeDataDevCommentType_To_ExpectedElementNames()
<AssemblyName>MyAssembly</AssemblyName>
</AssemblyInfo>
<Docs>
<summary>Langword <see langword=""true"" />. Paramref <see paramref=""myParam"" />. Typeparamref <see typeparamref=""myTypeParam"" />.</summary>
<summary>Langword <see langword=""true"" />. Paramref <paramref name=""myParam"" />. Typeparamref <typeparamref name=""myTypeParam"" />.</summary>
<remarks>
<format type=""text/markdown""><![CDATA[
Expand Down

0 comments on commit dea5237

Please sign in to comment.