فهرست منبع

2007-10-19 Atsushi Enomoto <[email protected]>

	* SubtreeXmlReader.cs : when a subtree reader is closed, the original
	  reader moves to the end of the subtree. Fixed bug #334752, patch by
	  Scott Peterson.

	* XmlReaderCommonTests.cs : added test for bug #334752.


svn path=/trunk/mcs/; revision=87812
Atsushi Eno 18 سال پیش
والد
کامیت
e977cbe8df

+ 6 - 0
mcs/class/System.XML/Mono.Xml/ChangeLog

@@ -1,3 +1,9 @@
+2007-10-19  Atsushi Enomoto <[email protected]>
+
+	* SubtreeXmlReader.cs : when a subtree reader is closed, the original
+	  reader moves to the end of the subtree. Fixed bug #334752, patch by
+	  Scott Peterson.
+
 2007-08-09  Atsushi Enomoto <[email protected]>
 
 	* SubtreeXmlReader.cs XmlFilterReader.cs : further dependent changes.

+ 2 - 1
mcs/class/System.XML/Mono.Xml/SubtreeXmlReader.cs

@@ -142,7 +142,8 @@ namespace Mono.Xml
 
 		public override void Close ()
 		{
-			// do nothing
+			while (Reader.Depth > startDepth && Read ())
+				;
 		}
 
 		public override string GetAttribute (int i)

+ 4 - 0
mcs/class/System.XML/Test/System.Xml/ChangeLog

@@ -1,3 +1,7 @@
+2007-10-19  Atsushi Enomoto  <[email protected]>
+
+	* XmlReaderCommonTests.cs : added test for bug #334752.
+
 2007-09-28  Atsushi Enomoto  <[email protected]>
 
 	* XmlWriterTests.cs : added WriteNodeXPathNavigatorAttribute().

+ 18 - 0
mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs

@@ -2001,6 +2001,24 @@ namespace MonoTests.System.Xml
 			AssertEquals (String.Empty, reader.ReadElementContentAsString ("sample", ""));
 			AssertEquals (XmlNodeType.EndElement, reader.NodeType);
 		}
+
+		[Test]
+		public void ReadSubtreeClose ()
+		{
+			// bug #334752
+			string xml = @"<root><item-list><item id='a'/><item id='b'/></item-list></root>";
+			RunTest (xml, new TestMethod (ReadSubtreeClose));
+		}
+
+		void ReadSubtreeClose (XmlReader reader)
+		{
+			reader.ReadToFollowing ("item-list");
+			XmlReader sub = reader.ReadSubtree ();
+			sub.ReadToDescendant ("item");
+			sub.Close ();
+			AssertEquals ("#1", XmlNodeType.EndElement, reader.NodeType);
+			AssertEquals ("#2", "item-list", reader.Name);
+		}
 #endif
 	}
 }