Sfoglia il codice sorgente

2006-10-13 Atsushi Enomoto <[email protected]>

	* ConfigurationSettings.cs : when there is no content in
	  sectionGroup, all the following contents were incorrectly read
	  as the empty group's subsection.


svn path=/trunk/mcs/; revision=66642
Atsushi Eno 19 anni fa
parent
commit
49516ee2f9

+ 6 - 0
mcs/class/System/System.Configuration/ChangeLog

@@ -1,3 +1,9 @@
+2006-10-13  Atsushi Enomoto  <[email protected]>
+
+	* ConfigurationSettings.cs : when there is no content in
+	  sectionGroup, all the following contents were incorrectly read
+	  as the empty group's subsection.
+
 2006-09-28  Andrew Skiba <[email protected]>
 
 	* ConfigurationSettings.cs: add support for requirePermission

+ 14 - 2
mcs/class/System/System.Configuration/ConfigurationSettings.cs

@@ -463,6 +463,7 @@ namespace System.Configuration
 			MoveToNextElement (reader);
 		}
 
+		// FIXME: this approach is not always safe and likely to cause bugs.
 		private void MoveToNextElement (XmlTextReader reader)
 		{
 			while (reader.Read ()) {
@@ -623,8 +624,19 @@ namespace System.Configuration
 				ThrowException ("Already have a factory for " + value, reader);
 
 			factories [value] = groupMark;
-			MoveToNextElement (reader);
-			ReadSections (reader, value);
+
+			if (reader.IsEmptyElement) {
+				reader.Skip ();
+				reader.MoveToContent ();
+			} else {
+				reader.Read ();
+				reader.MoveToContent ();
+				if (reader.NodeType != XmlNodeType.EndElement)
+					ReadSections (reader, value);
+				else
+					reader.Read ();
+				reader.MoveToContent ();
+			}
 		}
 
 		private void ReadSections (XmlTextReader reader, string configSection)