Author: atsushi
Date: 2008-01-26 05:01:07 -0500 (Sat, 26 Jan 2008)
New Revision: 93981

Modified:
   trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
   trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeReader.cs
   trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog
   trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeReaderTest.cs
Log:
2008-01-26  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * XNodeReader.cs : fixed GetAttribute() that wrongly resulted in
          returning "" instead of null. Fixed bug #335975.

        * XNodeReaderTest.cs : test for bug #335975.



Modified: trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
===================================================================
--- trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog   2008-01-26 
08:42:04 UTC (rev 93980)
+++ trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog   2008-01-26 
10:01:07 UTC (rev 93981)
@@ -1,3 +1,8 @@
+2008-01-26  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XNodeReader.cs : fixed GetAttribute() that wrongly resulted in
+         returning "" instead of null. Fixed bug #335975.
+
 2007-11-27  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XStreamingElement.cs : implement some members.

Modified: trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeReader.cs
===================================================================
--- trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeReader.cs      
2008-01-26 08:42:04 UTC (rev 93980)
+++ trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeReader.cs      
2008-01-26 10:01:07 UTC (rev 93981)
@@ -234,6 +234,8 @@
 
                public override string Value {
                        get {
+                               if (ReadState != ReadState.Interactive)
+                                       return String.Empty;
                                XAttribute a = GetCurrentAttribute ();
                                if (a != null)
                                        return a.Value;
@@ -385,9 +387,9 @@
                {
                        int a_bak = attr;
                        bool av_bak = attr_value;
-                       MoveToElement ();
-                       MoveToAttribute (i);
                        try {
+                               MoveToElement ();
+                               MoveToAttribute (i);
                                return Value;
                        } finally {
                                attr = a_bak;
@@ -399,10 +401,9 @@
                {
                        int a_bak = attr;
                        bool av_bak = attr_value;
-                       MoveToElement ();
-                       MoveToAttribute (name);
                        try {
-                               return Value;
+                               MoveToElement ();
+                               return MoveToAttribute (name) ? Value : null;
                        } finally {
                                attr = a_bak;
                                attr_value = av_bak;
@@ -413,10 +414,9 @@
                {
                        int a_bak = attr;
                        bool av_bak = attr_value;
-                       MoveToElement ();
-                       MoveToAttribute (local, ns);
                        try {
-                               return Value;
+                               MoveToElement ();
+                               return MoveToAttribute (local, ns) ? Value : 
null;
                        } finally {
                                attr = a_bak;
                                attr_value = av_bak;

Modified: trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog
===================================================================
--- trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog      
2008-01-26 08:42:04 UTC (rev 93980)
+++ trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog      
2008-01-26 10:01:07 UTC (rev 93981)
@@ -1,3 +1,7 @@
+2008-01-26  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XNodeReaderTest.cs : test for bug #335975.
+
 2007-10-26  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XTextTest.cs : added test for ToString().

Modified: 
trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeReaderTest.cs
===================================================================
--- trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeReaderTest.cs     
2008-01-26 08:42:04 UTC (rev 93980)
+++ trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeReaderTest.cs     
2008-01-26 10:01:07 UTC (rev 93981)
@@ -65,5 +65,19 @@
                        xw.Close ();
                        Assert.AreEqual (xml.Replace ('\'', '"'), sw.ToString 
());
                }
+
+               [Test]
+               public void GetAttribute ()
+               {
+                       // bug #335975
+                       var rdr = new StringReader 
("<root><val>Value</val></root>");
+                       var xDoc = XDocument.Load (rdr);
+                       XmlReader r = xDoc.CreateReader ();
+                       Assert.AreEqual (String.Empty, r.Value, "#1");
+                       Assert.IsNull (r.GetAttribute ("nil", 
"http://www.w3.org/2001/XMLSchema-instance";), "#2");
+                       r.Read ();
+                       Assert.AreEqual (String.Empty, r.Value, "#3");
+                       Assert.IsNull (r.GetAttribute ("nil", 
"http://www.w3.org/2001/XMLSchema-instance";), "#4");
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to