2006-10-13 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 13 Oct 2006 15:13:38 +0000 (15:13 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 13 Oct 2006 15:13:38 +0000 (15:13 -0000)
* ConfigurationSettings.cs : another MoveToNextElement() elimination.
  When there is another section group after "system.drawing"
  section in the existing machine.config, it borked as if there were
  no "system.diagnostics" section.

  It is still buggy; prepended sectionGroup still causes the above.

svn path=/trunk/mcs/; revision=66644

mcs/class/System/System.Configuration/ChangeLog
mcs/class/System/System.Configuration/ConfigurationSettings.cs

index 83094cbdcdb86d6e83c5397edf2cda243291b0f6..50f624191b2deaf30af0d79e9435ed89920f2871 100644 (file)
@@ -1,3 +1,12 @@
+2006-10-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConfigurationSettings.cs : another MoveToNextElement() elimination.
+         When there is another section group after "system.drawing"
+         section in the existing machine.config, it borked as if there were
+         no "system.diagnostics" section.
+
+         It is still buggy; prepended sectionGroup still causes the above.
+
 2006-10-13  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ConfigurationSettings.cs : when there is no content in
index 49f0b5f98e95bec6833ff1d4f253ce444f8ef8f1..aac2d43cdbbc146ab77e16906559eeab2cc22c5d 100644 (file)
@@ -302,8 +302,8 @@ namespace System.Configuration
                                }
 #endif
                                reader = new XmlTextReader (fs);
-                               InitRead (reader);
-                               ReadConfigFile (reader);
+                               if (InitRead (reader))
+                                       ReadConfigFile (reader);
                        } catch (ConfigurationException) {
                                throw;
                        } catch (Exception e) {
@@ -451,7 +451,7 @@ namespace System.Configuration
                        return null;
                }
 #if (XML_DEP)
-               private void InitRead (XmlTextReader reader)
+               private bool InitRead (XmlTextReader reader)
                {
                        reader.MoveToContent ();
                        if (reader.NodeType != XmlNodeType.Element || reader.Name != "configuration")
@@ -459,8 +459,13 @@ namespace System.Configuration
 
                        if (reader.HasAttributes)
                                ThrowException ("Unrecognized attribute in root element", reader);
-
-                       MoveToNextElement (reader);
+                       if (reader.IsEmptyElement) {
+                               reader.Skip ();
+                               return false;
+                       }
+                       reader.Read ();
+                       reader.MoveToContent ();
+                       return reader.NodeType != XmlNodeType.EndElement;
                }
 
                // FIXME: this approach is not always safe and likely to cause bugs.
@@ -684,15 +689,23 @@ namespace System.Configuration
                private void ReadConfigFile (XmlTextReader reader)
                {
                        int depth = reader.Depth;
-                       while (!reader.EOF && reader.Depth == depth) {
+                       for (reader.MoveToContent ();
+                            !reader.EOF && reader.NodeType != XmlNodeType.EndElement;
+                            reader.MoveToContent ()) {
                                string name = reader.Name;
                                if (name == "configSections") {
                                        if (reader.HasAttributes)
                                                ThrowException ("Unrecognized attribute in <configSections>.", reader);
-
-                                       MoveToNextElement (reader);
-                                       if (reader.Depth > depth)
-                                               ReadSections (reader, null);
+                                       if (reader.IsEmptyElement)
+                                               reader.Skip ();
+                                       else {
+                                               reader.Read ();
+                                               reader.MoveToContent ();
+                                               if (reader.NodeType != XmlNodeType.EndElement)
+                                                       ReadSections (reader, null);
+                                               else
+                                                       reader.Read ();
+                                       }
                                } else if (name != null && name != "") {
                                        StorePending (name, reader);
                                        MoveToNextElement (reader);