Skip to content

Commit 8b5f458

Browse files
committed
Merge branch 'mdoc-specialchars' into v5.0-preview
2 parents f05ba3f + 0ed15c1 commit 8b5f458

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

mdoc/Mono.Documentation/monodocer.cs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,41 @@ static bool UpdateAssemblyVersionForAssemblyInfo (XmlElement e, XmlElement root,
25422542
"System.Runtime.CompilerServices.DynamicAttribute",
25432543
};
25442544

2545+
private IEnumerable<char> FilterSpecialChars (string value)
2546+
{
2547+
foreach (char c in value) {
2548+
switch (c) {
2549+
case '\0':
2550+
yield return '\\';
2551+
yield return '0';
2552+
break;
2553+
case '\t':
2554+
yield return '\\';
2555+
yield return 't';
2556+
break;
2557+
case '\n':
2558+
yield return '\\';
2559+
yield return 'n';
2560+
break;
2561+
case '\r':
2562+
yield return '\\';
2563+
yield return 'r';
2564+
break;
2565+
case '\f':
2566+
yield return '\\';
2567+
yield return 'f';
2568+
break;
2569+
case '\b':
2570+
yield return '\\';
2571+
yield return 'b';
2572+
break;
2573+
default:
2574+
yield return c;
2575+
break;
2576+
}
2577+
}
2578+
}
2579+
25452580
private void MakeAttributes (XmlElement root, IEnumerable<string> attributes, TypeReference t=null)
25462581
{
25472582
if (!attributes.Any ()) {
@@ -2555,11 +2590,12 @@ private void MakeAttributes (XmlElement root, IEnumerable<string> attributes, Ty
25552590
else if (e == null)
25562591
e = root.OwnerDocument.CreateElement("Attributes");
25572592

2593+
25582594
foreach (string attribute in attributes) {
25592595
XmlElement ae = root.OwnerDocument.CreateElement("Attribute");
25602596
e.AppendChild(ae);
2561-
2562-
WriteElementText(ae, "AttributeName", attribute);
2597+
var value = new String (FilterSpecialChars (attribute).ToArray ());
2598+
WriteElementText(ae, "AttributeName", value);
25632599
}
25642600

25652601
if (e.ParentNode == null)

mdoc/Test/DocTest-InternalInterface.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ internal interface MyInternalInterface {
77
}
88

99
public class MyClass : MyInternalInterface {
10+
[System.ComponentModel.DefaultValue ('\0')]
1011
public string Bar {get;set;}
1112
public void BarMeth () {} // part of the interface, but publicly implemented
1213

mdoc/Test/en.expected-internal-interface/MyNamespace/MyClass.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
<AssemblyInfo>
3535
<AssemblyVersion>0.0.0.0</AssemblyVersion>
3636
</AssemblyInfo>
37+
<Attributes>
38+
<Attribute>
39+
<AttributeName>System.ComponentModel.DefaultValue('\0')</AttributeName>
40+
</Attribute>
41+
</Attributes>
3742
<ReturnValue>
3843
<ReturnType>System.String</ReturnType>
3944
</ReturnValue>

0 commit comments

Comments
 (0)