diff options
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 7 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlElement.cs | 6 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs | 17 |
4 files changed, 34 insertions, 2 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index 0edca49b732..60c36089104 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,10 @@ +2005-12-26 Atsushi Enomoto <atsushi@ximian.com> + + * XmlElement.cs : patch for Prefix property by Vorobiev Maksim. + - null should cause ArgumentNullException. + - "" should not raise an error. + - throws ArgumentException when it is readonly. + 2005-12-23 Atsushi Enomoto <atsushi@ximian.com> * XmlTextWriter.cs : When xml:space or xml:lang attribute was diff --git a/mcs/class/System.XML/System.Xml/XmlElement.cs b/mcs/class/System.XML/System.Xml/XmlElement.cs index 1ba651f6185..b008b0c0ff1 100644 --- a/mcs/class/System.XML/System.Xml/XmlElement.cs +++ b/mcs/class/System.XML/System.Xml/XmlElement.cs @@ -215,8 +215,10 @@ namespace System.Xml get { return name.Prefix; } set { if (IsReadOnly) - throw new XmlException ("This node is readonly."); - if (!XmlChar.IsNCName (value)) + throw new ArgumentException ("This node is readonly."); + if (value == null) + throw new ArgumentNullException("Prefix value is null."); + if ((!String.Empty.Equals(value))&&(!XmlChar.IsNCName (value))) throw new ArgumentException ("Specified name is not a valid NCName: " + value); value = OwnerDocument.NameTable.Add (value); diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog index 78e50b7b722..bed9f0ed172 100644 --- a/mcs/class/System.XML/Test/System.Xml/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog @@ -1,5 +1,11 @@ 2005-12-26 Atsushi Enomoto <atsushi@ximian.com> + * XmlElementTests.cs : Patch by Vorobiev Maksim. + - setting null to Prefix should raise ArgumentNullException. + - setting String.Empty to Prefix should be allowed. + +2005-12-26 Atsushi Enomoto <atsushi@ximian.com> + * XsdValidatingReaderTests.cs : test for multi URLs in schemaLocation. Test by Vorobiev Maskim. diff --git a/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs index 07ef8032e12..89af454522c 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs @@ -559,5 +559,22 @@ namespace MonoTests.System.Xml document.DocumentElement.WriteTo (xtw); AssertEquals ("<root>&foo;</root>", sw.ToString ()); } + + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void SetNullPrefix () + { + XmlDocument doc = new XmlDocument (); + doc.LoadXml ("<root/>"); + doc.DocumentElement.Prefix = null; + } + + [Test] + public void SetEmptyStringPrefix () + { + XmlDocument doc = new XmlDocument (); + doc.LoadXml ("<root/>"); + doc.DocumentElement.Prefix = String.Empty; + } } } |