Fix loading of documentation XML fragments to use source file and not process path
authorMarek Safar <marek.safar@gmail.com>
Sun, 24 Feb 2013 11:42:59 +0000 (12:42 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 25 Feb 2013 13:11:02 +0000 (14:11 +0100)
mcs/errors/cs0650.cs
mcs/errors/cs1589-2.cs [new file with mode: 0644]
mcs/errors/cs1589.cs
mcs/errors/cs1592.cs [deleted file]
mcs/mcs/doc.cs
mcs/tests/dlls/test-xml-025-relative.cs [new file with mode: 0644]
mcs/tests/dlls/test-xml-025-relative.inc [new file with mode: 0644]
mcs/tests/test-xml-025-ref.xml
mcs/tests/test-xml-025.cs

index 48531a27dcf8f4e4f1aab3b73f5bb0a8fac899b1..1d5cff83d2b28e741f9c593532717188c58b419b 100644 (file)
@@ -1,4 +1,4 @@
-// CS0650: Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable`s identifier. To declare a fixed size buffer field, use the fixed keyword before the field type
+// CS0650: Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type
 // Line: 7
 
 class X {
diff --git a/mcs/errors/cs1589-2.cs b/mcs/errors/cs1589-2.cs
new file mode 100644 (file)
index 0000000..d4bd739
--- /dev/null
@@ -0,0 +1,17 @@
+// CS1589: Unable to include XML fragment `/foo/bar' of file `there-is-no-such-file'. Could not find file "*PATH*/there-is-no-such-file"
+// Line: 12
+// Compiler options: -doc:dummy.xml -warn:1 -warnaserror
+
+namespace Testing
+{
+   /// blah
+   public class Test
+   {
+       // warning
+       /// <include file='there-is-no-such-file' path='/foo/bar' />
+       public void Baz (int x)
+       {
+       }
+   }
+}
+
index 3bf76ce981de88227cf3dcbdfeba1e4181c4a2c5..71bfe94f07c02e79bb8bbd06fc7bdd2dcbf35b94 100644 (file)
@@ -1,4 +1,4 @@
-// CS1589: Unable to include XML fragment `/root/@attr' of file `cs1589.inc' (Cannot insert specified type of node as a child of this node.)
+// CS1589: Unable to include XML fragment `/root/@attr' of file `cs1589.inc'. Cannot insert specified type of node as a child of this node
 // Line: 15
 // Compiler options: -doc:dummy.xml -warn:1 -warnaserror
 
diff --git a/mcs/errors/cs1592.cs b/mcs/errors/cs1592.cs
deleted file mode 100644 (file)
index 12cc220..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// CS1592: Badly formed XML in included comments file -- `there-is-no-such-file'
-// Line: 12
-// Compiler options: -doc:dummy.xml -warn:1 -warnaserror
-
-namespace Testing
-{
-   /// blah
-   public class Test
-   {
-       // warning
-       /// <include file='there-is-no-such-file' path='/foo/bar' />
-       public void Baz (int x)
-       {
-       }
-   }
-}
-
index 6cc53d505383d077e6cf08136e2280b98f193952..46fdb3c9e1555239000539caa08551ed7ee1273f 100644 (file)
@@ -175,28 +175,31 @@ namespace Mono.CSharp
                        bool keep_include_node = false;
                        string file = el.GetAttribute ("file");
                        string path = el.GetAttribute ("path");
+
                        if (file == "") {
                                Report.Warning (1590, 1, mc.Location, "Invalid XML `include' element. Missing `file' attribute");
                                el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
                                keep_include_node = true;
-                       }
-                       else if (path.Length == 0) {
+                       } else if (path.Length == 0) {
                                Report.Warning (1590, 1, mc.Location, "Invalid XML `include' element. Missing `path' attribute");
                                el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
                                keep_include_node = true;
-                       }
-                       else {
+                       } else {
                                XmlDocument doc;
-                               if (!StoredDocuments.TryGetValue (file, out doc)) {
+                               Exception exception = null;
+                               var full_path = Path.Combine (Path.GetDirectoryName (mc.Location.NameFullPath), file);
+
+                               if (!StoredDocuments.TryGetValue (full_path, out doc)) {
                                        try {
                                                doc = new XmlDocument ();
-                                               doc.Load (file);
-                                               StoredDocuments.Add (file, doc);
-                                       } catch (Exception) {
+                                               doc.Load (full_path);
+                                               StoredDocuments.Add (full_path, doc);
+                                       } catch (Exception e) {
+                                               exception = e;
                                                el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (String.Format (" Badly formed XML in at comment file `{0}': cannot be included ", file)), el);
-                                               Report.Warning (1592, 1, mc.Location, "Badly formed XML in included comments file -- `{0}'", file);
                                        }
                                }
+
                                if (doc != null) {
                                        try {
                                                XmlNodeList nl = doc.SelectNodes (path);
@@ -208,11 +211,17 @@ namespace Mono.CSharp
                                                foreach (XmlNode n in nl)
                                                        el.ParentNode.InsertBefore (el.OwnerDocument.ImportNode (n, true), el);
                                        } catch (Exception ex) {
+                                               exception = ex;
                                                el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Failed to insert some or all of included XML "), el);
-                                               Report.Warning (1589, 1, mc.Location, "Unable to include XML fragment `{0}' of file `{1}' ({2})", path, file, ex.Message);
                                        }
                                }
+
+                               if (exception != null) {
+                                       Report.Warning (1589, 1, mc.Location, "Unable to include XML fragment `{0}' of file `{1}'. {2}",
+                                               path, file, exception.Message);
+                               }
                        }
+
                        return keep_include_node;
                }
 
diff --git a/mcs/tests/dlls/test-xml-025-relative.cs b/mcs/tests/dlls/test-xml-025-relative.cs
new file mode 100644 (file)
index 0000000..5dc2107
--- /dev/null
@@ -0,0 +1,10 @@
+public class RelativeTestPath
+{
+    /// <summary>
+    /// Implements more features
+    /// </summary>
+    /// <include file='test-xml-025-relative.inc' path='/doc/remarks[@name="Foo"]'/>
+    public static void Foo ()
+    {
+    }
+}
\ No newline at end of file
diff --git a/mcs/tests/dlls/test-xml-025-relative.inc b/mcs/tests/dlls/test-xml-025-relative.inc
new file mode 100644 (file)
index 0000000..978bed4
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<doc>
+  <remarks name="Foo">
+    implements the method in the most beautiful way possible.
+</remarks>
+</doc>    
\ No newline at end of file
index 8e7551ee2649a60ec27b5e36d2a1dc832bbe0ef3..fe5448ab1735bd77fa40b8fa42d2736026bd5e56 100644 (file)
@@ -1,24 +1,32 @@
-<?xml version="1.0"?>\r
-<doc>\r
-    <assembly>\r
-        <name>test-xml-025</name>\r
-    </assembly>\r
-    <members>\r
-        <member name="T:Testing.Test">\r
-            <!-- No matching elements were found for the following include tag --><include file="test-xml-025.inc" path="/foo"/>\r
-        </member>\r
-        <member name="F:Testing.Test.S1">\r
-            <root attr="is attribute allowed?">\r
-  includes XML markup.\r
-  <child>test</child>\r
-  <child>test2</child>\r
-</root>\r
-        </member>\r
-        <member name="F:Testing.Test.S2">\r
-            <child>test</child><child>test2</child>\r
-        </member>\r
-        <member name="F:Testing.Test.S3">\r
-            <!-- Failed to insert some or all of included XML -->\r
-        </member>\r
-    </members>\r
-</doc>\r
+<?xml version="1.0"?>
+<doc>
+    <assembly>
+        <name>test-xml-025</name>
+    </assembly>
+    <members>
+        <member name="T:Testing.Test">
+            <!-- No matching elements were found for the include tag embedded here. -->
+            <include file="test-xml-025.inc" path="/foo" />
+        </member>
+        <member name="F:Testing.Test.S1">
+            <root attr="is attribute allowed?">
+  includes XML markup.
+  <child>test</child><child>test2</child></root>
+        </member>
+        <member name="F:Testing.Test.S2">
+            <child>test</child>
+            <child>test2</child>
+        </member>
+        <member name="F:Testing.Test.S3">
+            <!-- Failed to insert some or all of included XML -->
+        </member>
+        <member name="M:RelativeTestPath.Foo">
+            <summary>
+            Implements more features
+            </summary>
+            <remarks name="Foo">
+    implements the method in the most beautiful way possible.
+</remarks>
+        </member>
+    </members>
+</doc>
index d04979490e9219aa4d8bd45494588e8550510627..66bcf70bbfec1f13c218d6f61b72150d861fba13 100644 (file)
@@ -1,4 +1,4 @@
-// Compiler options: -doc:xml-025.xml
+// Compiler options: -doc:xml-025.xml dlls/test-xml-025-relative.cs
 
 namespace Testing
 {