[mcs] Keep documentation formatting as was written in source code. Fixes #34409
authorMarek Safar <marek.safar@gmail.com>
Mon, 5 Oct 2015 14:05:51 +0000 (16:05 +0200)
committerMarek Safar <marek.safar@gmail.com>
Mon, 5 Oct 2015 14:05:51 +0000 (16:05 +0200)
16 files changed:
mcs/errors/cs1570-10.cs
mcs/errors/cs1570-11.cs
mcs/errors/cs1570-12.cs
mcs/errors/cs1570-2.cs
mcs/errors/cs1570-3.cs
mcs/errors/cs1570-4.cs
mcs/errors/cs1570-5.cs
mcs/errors/cs1570-6.cs
mcs/errors/cs1570-7.cs
mcs/errors/cs1570-8.cs
mcs/errors/cs1570-9.cs
mcs/errors/cs1570.cs
mcs/mcs/cs-tokenizer.cs
mcs/mcs/doc.cs
mcs/tests/test-xml-073-ref.xml [new file with mode: 0644]
mcs/tests/test-xml-073.cs [new file with mode: 0644]

index 54c9b9ed8b87a68a701676d1c601bb4c0f20f718..8edae88d54c9820fb37509e3eff2285410067961 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Testing.Test.PrivateField2' is not well-formed XML markup (The 'summary' start tag on line 1 position 2 does not match the end tag of 'incorrect'. Line 3, position 3.)
+// CS1570: XML documentation comment on `Testing.Test.PrivateField2' is not well-formed XML markup (The 'summary' start tag on line 1 position 3 does not match the end tag of 'incorrect'. Line 3, position 4.)
 // Line: 23
 // Compiler options: -doc:dummy.xml -warn:1 -warnaserror
 
index fbe650d2c5fe1a3d36e46a62a4354b77400000f3..44584a8dd1cdc46ef9d8571a9c10e9cd9bec765d 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Testing.Test.PublicProperty2' is not well-formed XML markup (The 'summary' start tag on line 1 position 2 does not match the end tag of 'incorrect'. Line 3, position 3.)
+// CS1570: XML documentation comment on `Testing.Test.PublicProperty2' is not well-formed XML markup (The 'summary' start tag on line 1 position 3 does not match the end tag of 'incorrect'. Line 3, position 4.)
 // Line: 32
 // Compiler options: -doc:dummy.xml -warn:1 -warnaserror
 
index 2ff33071608d2521b9ce6c2777bf369de3a492aa..1284950a431f30acf23c00ae075e65009927bff2 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Test' is not well-formed XML markup (Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 3, position 3.)
+// CS1570: XML documentation comment on `Test' is not well-formed XML markup (Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 3, position 4.)
 // Line: 13
 // Compiler options: -doc:dummy.xml -warnaserror -warn:1
 
index 67843d33c97aa8d608b2f46aa1c494e71906889d..7566d206ad45761382e4d3100954389225a5b293 100644 (file)
@@ -6,9 +6,9 @@ using System;
 
 namespace Testing
 {
-       /// <summary>
+       ///<summary>
        /// Incorrect comment markup.
-       /// </incorrect>
+       ///</incorrect>
        public class Test2
        {
        }
index 67c7228f0062618116ec31c77c930b55b848e7a2..a1b1b8747e014ff8929d115948f62c3f652a3b18 100644 (file)
@@ -4,9 +4,9 @@
 
 namespace Testing
 {
-       /// <summary> 
+       ///<summary> 
        /// incorrect markup comment for struct
-       /// </incorrect>
+       ///</incorrect>
        public struct StructTest2
        {
        }
index b0d6cf7d5eb8b61c4f91e778d408d3eaa78f9e8e..0f50aff278a79a577122a31925a34d845495c535 100644 (file)
@@ -6,9 +6,9 @@ using System;
 
 namespace Testing
 {
-       /// <summary>
+       ///<summary>
        /// incorrect markup comment for interface
-       /// </incorrect>
+       ///</incorrect>
        public interface InterfaceTest2
        {
        }
index 735bdafb92fcef99cc85227ecc8fd02398964f89..a73342179c96a1ef34f57ef015ba68c71830ba87 100644 (file)
@@ -6,9 +6,9 @@ using System;
 
 namespace Testing
 {
-       /// <summary>
+       ///<summary>
        /// comment for enum type
-       /// </incorrect>
+       ///</incorrect>
        enum EnumTest2
        {
                Foo,
index e7098ee1c1d1e8518b23a2da18cbcce615341640..cec74ba11f5f6a3843b551751d96843d10ba9c1e 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Testing.MyDelegate2' is not well-formed XML markup (The 'summary' start tag on line 1 position 2 does not match the end tag of 'incorrect'. Line 3, position 3.)
+// CS1570: XML documentation comment on `Testing.MyDelegate2' is not well-formed XML markup (The 'summary' start tag on line 1 position 3 does not match the end tag of 'incorrect'. Line 3, position 4.)
 // Line: 12
 // Compiler options: -doc:dummy.xml -warn:1 -warnaserror
 
index 75a9a3b5ff4791f92c684a3ffc060928ddf4b767..2d3335ff989cceb6d4457d743fb55630b0c32172 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Testing.Test2' is not well-formed XML markup (Name cannot begin with the '6' character, hexadecimal value 0x36. Line 1, position 2.)
+// CS1570: XML documentation comment on `Testing.Test2' is not well-formed XML markup (Name cannot begin with the '6' character, hexadecimal value 0x36. Line 1, position 3.)
 // Line: 9
 // Compiler options: -doc:dummy.xml -warn:1 -warnaserror
 
index bec4e007eebfd0052437c734afeae14853033ed2..bec54e186f259fbfc37e7696829b19e7efa0ac05 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Testing.Test.Constant2' is not well-formed XML markup (The 'summary' start tag on line 1 position 2 does not match the end tag of 'invalid'. Line 3, position 3.)
+// CS1570: XML documentation comment on `Testing.Test.Constant2' is not well-formed XML markup (The 'summary' start tag on line 1 position 3 does not match the end tag of 'invalid'. Line 3, position 4.)
 // Line: 19
 // Compiler options: -doc:dummy.xml -warn:1 -warnaserror
 
index 15731039843a1286a043e95119aaed0255f3bf7f..8f8f4c82a9c56c953b98252a551bf70494dbf633 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Testing.Test.PublicField2' is not well-formed XML markup (The 'summary' start tag on line 1 position 2 does not match the end tag of 'invalid'. Line 3, position 3.)
+// CS1570: XML documentation comment on `Testing.Test.PublicField2' is not well-formed XML markup (The 'summary' start tag on line 1 position 3 does not match the end tag of 'invalid'. Line 3, position 4.)
 // Line: 19
 // Compiler options: -doc:dummy.xml -warn:1 -warnaserror
 
index 88bfd282a6f828156f727a1a1916e760a2ffe940..c809e4389081210dc9125d0ec19a0c24fadc2c29 100644 (file)
@@ -1,4 +1,4 @@
-// CS1570: XML documentation comment on `Testing.Test2' is not well-formed XML markup (The 'summary' start tag on line 1 position 2 does not match the end tag of 'incorrect'. Line 3, position 3.)
+// CS1570: XML documentation comment on `Testing.Test2' is not well-formed XML markup (The 'summary' start tag on line 1 position 3 does not match the end tag of 'incorrect'. Line 3, position 4.)
 // Line: 12
 // Compiler options: -doc:dummy.xml -warnaserror -warn:1
 
index 02f6f3df77494ae11eec7fda3dd1b388fd94fc9b..c46fbc92f5477cee2195e0fed0b33adc6d53505e 100644 (file)
@@ -4101,8 +4101,6 @@ namespace Mono.CSharp
                private void handle_one_line_xml_comment ()
                {
                        int c;
-                       while ((c = peek_char ()) == ' ')
-                               get_char (); // skip heading whitespaces.
                        while ((c = peek_char ()) != -1 && c != '\n' && c != '\r') {
                                xml_comment_buffer.Append ((char) get_char ());
                        }
index adf6ea082d007b971c433a99e4b258aa7c0ba882..296faded937ff51c83192f1636673fae75fa1d2e 100644 (file)
@@ -92,22 +92,9 @@ namespace Mono.CSharp
                                el.SetAttribute ("name", name);
                                string normalized = mc.DocComment;
                                el.InnerXml = normalized;
-                               // csc keeps lines as written in the sources
-                               // and inserts formatting indentation (which 
-                               // is different from XmlTextWriter.Formatting
-                               // one), but when a start tag contains an 
-                               // endline, it joins the next line. We don't
-                               // have to follow such a hacky behavior.
-                               string [] split =
-                                       normalized.Split ('\n');
-                               int j = 0;
-                               for (int i = 0; i < split.Length; i++) {
-                                       string s = split [i].TrimEnd ();
-                                       if (s.Length > 0)
-                                               split [j++] = s;
-                               }
-                               el.InnerXml = line_head + String.Join (
-                                       line_head, split, 0, j);
+
+                               string [] split = normalized.Split ('\n');
+                               el.InnerXml = line_head + String.Join (line_head, split);
                                return el;
                        } catch (Exception ex) {
                                Report.Warning (1570, 1, mc.Location, "XML documentation comment on `{0}' is not well-formed XML markup ({1})",
diff --git a/mcs/tests/test-xml-073-ref.xml b/mcs/tests/test-xml-073-ref.xml
new file mode 100644 (file)
index 0000000..a67bfe5
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<doc>
+    <assembly>
+        <name>test-xml-073</name>
+    </assembly>
+    <members>
+        <member name="T:X">
+            <text>
+            A line
+            
+               An indented line
+            </text>
+            </member>
+    </members>
+</doc>
diff --git a/mcs/tests/test-xml-073.cs b/mcs/tests/test-xml-073.cs
new file mode 100644 (file)
index 0000000..9c65c82
--- /dev/null
@@ -0,0 +1,13 @@
+// Compiler options: -doc:xml-073.xml
+///<text>
+///A line
+///
+///   An indented line
+///</text>
+class X
+{
+    public static void Main ()
+    {
+
+    }
+}
\ No newline at end of file