From 3156d1b05d75a2f70f1f2a882dab031a8ceed9f9 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 5 Oct 2015 16:05:51 +0200 Subject: [PATCH] [mcs] Keep documentation formatting as was written in source code. Fixes #34409 --- mcs/errors/cs1570-10.cs | 2 +- mcs/errors/cs1570-11.cs | 2 +- mcs/errors/cs1570-12.cs | 2 +- mcs/errors/cs1570-2.cs | 4 ++-- mcs/errors/cs1570-3.cs | 4 ++-- mcs/errors/cs1570-4.cs | 4 ++-- mcs/errors/cs1570-5.cs | 4 ++-- mcs/errors/cs1570-6.cs | 2 +- mcs/errors/cs1570-7.cs | 2 +- mcs/errors/cs1570-8.cs | 2 +- mcs/errors/cs1570-9.cs | 2 +- mcs/errors/cs1570.cs | 2 +- mcs/mcs/cs-tokenizer.cs | 2 -- mcs/mcs/doc.cs | 19 +++---------------- mcs/tests/test-xml-073-ref.xml | 15 +++++++++++++++ mcs/tests/test-xml-073.cs | 13 +++++++++++++ 16 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 mcs/tests/test-xml-073-ref.xml create mode 100644 mcs/tests/test-xml-073.cs diff --git a/mcs/errors/cs1570-10.cs b/mcs/errors/cs1570-10.cs index 54c9b9ed8b8..8edae88d54c 100644 --- a/mcs/errors/cs1570-10.cs +++ b/mcs/errors/cs1570-10.cs @@ -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 diff --git a/mcs/errors/cs1570-11.cs b/mcs/errors/cs1570-11.cs index fbe650d2c5f..44584a8dd1c 100644 --- a/mcs/errors/cs1570-11.cs +++ b/mcs/errors/cs1570-11.cs @@ -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 diff --git a/mcs/errors/cs1570-12.cs b/mcs/errors/cs1570-12.cs index 2ff33071608..1284950a431 100644 --- a/mcs/errors/cs1570-12.cs +++ b/mcs/errors/cs1570-12.cs @@ -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 diff --git a/mcs/errors/cs1570-2.cs b/mcs/errors/cs1570-2.cs index 67843d33c97..7566d206ad4 100644 --- a/mcs/errors/cs1570-2.cs +++ b/mcs/errors/cs1570-2.cs @@ -6,9 +6,9 @@ using System; namespace Testing { - /// + /// /// Incorrect comment markup. - /// + /// public class Test2 { } diff --git a/mcs/errors/cs1570-3.cs b/mcs/errors/cs1570-3.cs index 67c7228f006..a1b1b8747e0 100644 --- a/mcs/errors/cs1570-3.cs +++ b/mcs/errors/cs1570-3.cs @@ -4,9 +4,9 @@ namespace Testing { - /// + /// /// incorrect markup comment for struct - /// + /// public struct StructTest2 { } diff --git a/mcs/errors/cs1570-4.cs b/mcs/errors/cs1570-4.cs index b0d6cf7d5eb..0f50aff278a 100644 --- a/mcs/errors/cs1570-4.cs +++ b/mcs/errors/cs1570-4.cs @@ -6,9 +6,9 @@ using System; namespace Testing { - /// + /// /// incorrect markup comment for interface - /// + /// public interface InterfaceTest2 { } diff --git a/mcs/errors/cs1570-5.cs b/mcs/errors/cs1570-5.cs index 735bdafb92f..a73342179c9 100644 --- a/mcs/errors/cs1570-5.cs +++ b/mcs/errors/cs1570-5.cs @@ -6,9 +6,9 @@ using System; namespace Testing { - /// + /// /// comment for enum type - /// + /// enum EnumTest2 { Foo, diff --git a/mcs/errors/cs1570-6.cs b/mcs/errors/cs1570-6.cs index e7098ee1c1d..cec74ba11f5 100644 --- a/mcs/errors/cs1570-6.cs +++ b/mcs/errors/cs1570-6.cs @@ -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 diff --git a/mcs/errors/cs1570-7.cs b/mcs/errors/cs1570-7.cs index 75a9a3b5ff4..2d3335ff989 100644 --- a/mcs/errors/cs1570-7.cs +++ b/mcs/errors/cs1570-7.cs @@ -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 diff --git a/mcs/errors/cs1570-8.cs b/mcs/errors/cs1570-8.cs index bec4e007eeb..bec54e186f2 100644 --- a/mcs/errors/cs1570-8.cs +++ b/mcs/errors/cs1570-8.cs @@ -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 diff --git a/mcs/errors/cs1570-9.cs b/mcs/errors/cs1570-9.cs index 15731039843..8f8f4c82a9c 100644 --- a/mcs/errors/cs1570-9.cs +++ b/mcs/errors/cs1570-9.cs @@ -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 diff --git a/mcs/errors/cs1570.cs b/mcs/errors/cs1570.cs index 88bfd282a6f..c809e438908 100644 --- a/mcs/errors/cs1570.cs +++ b/mcs/errors/cs1570.cs @@ -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 diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs index 02f6f3df774..c46fbc92f54 100644 --- a/mcs/mcs/cs-tokenizer.cs +++ b/mcs/mcs/cs-tokenizer.cs @@ -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 ()); } diff --git a/mcs/mcs/doc.cs b/mcs/mcs/doc.cs index adf6ea082d0..296faded937 100644 --- a/mcs/mcs/doc.cs +++ b/mcs/mcs/doc.cs @@ -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 index 00000000000..a67bfe578a2 --- /dev/null +++ b/mcs/tests/test-xml-073-ref.xml @@ -0,0 +1,15 @@ + + + + test-xml-073 + + + + + A line + + An indented line + + + + diff --git a/mcs/tests/test-xml-073.cs b/mcs/tests/test-xml-073.cs new file mode 100644 index 00000000000..9c65c82ef51 --- /dev/null +++ b/mcs/tests/test-xml-073.cs @@ -0,0 +1,13 @@ +// Compiler options: -doc:xml-073.xml +/// +///A line +/// +/// An indented line +/// +class X +{ + public static void Main () + { + + } +} \ No newline at end of file -- 2.25.1