2008-04-16 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Wed, 16 Apr 2008 21:52:54 +0000 (21:52 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 16 Apr 2008 21:52:54 +0000 (21:52 -0000)
* ReferenceConverter.cs: fix ConvertFrom and ConvertTo when
converting from/to string - base must be called only if the
conversion target type is NOT string, otherwise the result of the
conversion will be the value type name.
2008-04-16  Marek Habersack  <mhabersack@novell.com>

* ComponentConverterTests.cs: added tests for
{Component, Reference}Converter ConvertFrom/ConvertTo changes.
2008-04-16  Marek Habersack  <mhabersack@novell.com>

* System_test.dll.sources: added
System.ComponentModel/ComponentConverterTests.cs

* Makefile (TEST_MCS_FLAGS): reference -r:System.Data for new
tests.

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

mcs/class/System/ChangeLog
mcs/class/System/Makefile
mcs/class/System/System.ComponentModel/ChangeLog
mcs/class/System/System.ComponentModel/ReferenceConverter.cs
mcs/class/System/System.dll.sources
mcs/class/System/System_test.dll.sources
mcs/class/System/Test/System.ComponentModel/ChangeLog
mcs/class/System/Test/System.ComponentModel/ComponentConverterTests.cs [new file with mode: 0644]

index 7ca878922e46bd218b29b491cd0d8444e9e3f936..8efdd077f7157eda6ac0395516496c5bea93259e 100644 (file)
@@ -1,3 +1,11 @@
+2008-04-16  Marek Habersack  <mhabersack@novell.com>
+
+       * System_test.dll.sources: added
+       System.ComponentModel/ComponentConverterTests.cs
+
+       * Makefile (TEST_MCS_FLAGS): reference -r:System.Data for new
+       tests.
+
 2008-04-13  Jb Evain  <jbevain@novell.com>
 
        * net_2_1_raw_System.dll.sources: tune out some
index 9b0c1e3d64ec2fa5b1ad9ac304f9bbb85aad0258..150b89eda2869b6855e2c8f1401e2b43f0c3e4ee 100644 (file)
@@ -20,7 +20,7 @@ TEST_RESOURCES = \
        Test/System/test-uri-props-manual.txt \
        Test/System/test-uri-relative-props.txt
 
-TEST_MCS_FLAGS = -r:System.Drawing.dll -r:Mono.Security.dll -nowarn:1595 -nowarn:0618 -nowarn:219 -nowarn:67 -nowarn:169 -nowarn:612 \
+TEST_MCS_FLAGS = -r:System.Drawing.dll -r:Mono.Security.dll -r:System.Data -nowarn:1595 -nowarn:0618 -nowarn:219 -nowarn:67 -nowarn:169 -nowarn:612 \
        $(foreach f, $(TEST_RESOURCES), -resource:$(f),$(notdir $(f)))
 
 ifeq (2, $(FRAMEWORK_VERSION_MAJOR))
index c1051e422bca2902b21a11cf5d1ade75c920b3a9..32cdb90879474777d66b09984ba5a1dbd57b2221 100644 (file)
@@ -1,3 +1,10 @@
+2008-04-16  Marek Habersack  <mhabersack@novell.com>
+
+       * ReferenceConverter.cs: fix ConvertFrom and ConvertTo when
+       converting from/to string - base must be called only if the
+       conversion target type is NOT string, otherwise the result of the
+       conversion will be the value type name.
+
 2008-04-13  Jb Evain  <jbevain@novell.com>
 
        * TypeDescriptor.cs: internalize method AddEditorTable
index 41cfd2a16e4996a5b32de86f8ce74938b81c81a4..92d5a27b0dac4237b65e8b1c865514da86f195a6 100644 (file)
@@ -54,9 +54,14 @@ namespace System.ComponentModel
                                                    CultureInfo culture,
                                                    object value)
                {
-                       if (value is string && ((string)value) == "(none)")
+                       if (!(value is string))
+                               return base.ConvertFrom(context, culture, value);
+                       
+                       if (((string)value) == "(none)")
                                return null;
-                       return base.ConvertFrom(context, culture, value);
+                       
+                       // There must be something else to do here...
+                       return null;
                }
 
                public override object ConvertTo (ITypeDescriptorContext context,
@@ -64,9 +69,13 @@ namespace System.ComponentModel
                                                  object value,
                                                  Type destinationType)
                {
-                       if (destinationType == typeof (string) && value == null)
+                       if (destinationType != typeof (string))
+                               return base.ConvertTo(context, culture, value, destinationType);
+                       
+                       if (value == null)
                                return "(none)";
-                       return base.ConvertTo(context, culture, value, destinationType);
+                       
+                       return String.Empty;
                }
 
                public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
index 1d6c8c846fb8a66d82208a6f375f9426ffc44a72..28fb53442d7873ff6b5901d317fd819027ef28a4 100644 (file)
@@ -563,6 +563,7 @@ System.IO/DefaultWatcher.cs
 System.IO/ErrorEventArgs.cs
 System.IO/ErrorEventHandler.cs
 System.IO/FAMWatcher.cs
+System.IO/NoOpWatcher.cs
 System.IO/FileAction.cs
 System.IO/FileSystemEventArgs.cs
 System.IO/FileSystemEventHandler.cs
index ff00bfc4541ad19ca7f7162c82e71cd5b0ad7a51..8c402a3a6b1eaaa4536401bc818725959f319e8e 100644 (file)
@@ -116,6 +116,7 @@ System.ComponentModel/ByteConverterTests.cs
 System.ComponentModel/CharConverterTest.cs
 System.ComponentModel/CollectionConverterTest.cs
 System.ComponentModel/ComplexBindingPropertiesAttributeTest.cs
+System.ComponentModel/ComponentConverterTests.cs
 System.ComponentModel/ComponentResourceManagerTest.cs
 System.ComponentModel/ContainerTest.cs
 System.ComponentModel/CultureInfoConverterTest.cs
index cd1f4b085781c93efb44db205822e5b96e8cbaf9..adb4fe5a14c5b7640c881f430c0570d490cc8976 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-16  Marek Habersack  <mhabersack@novell.com>
+
+       * ComponentConverterTests.cs: added tests for
+       {Component, Reference}Converter ConvertFrom/ConvertTo changes.
+
 2008-03-15  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * DesignerAttributeTest.cs: Added ctor tests.
diff --git a/mcs/class/System/Test/System.ComponentModel/ComponentConverterTests.cs b/mcs/class/System/Test/System.ComponentModel/ComponentConverterTests.cs
new file mode 100644 (file)
index 0000000..3f4451c
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// System.ComponentModel.TypeConverter test cases
+//
+// Authors:
+//     Marek Habersack (mhabersack@novell.com)
+//
+// (c) 2008 Novell, Inc. (http://novell.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Data;
+using System.Globalization;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ComponentModel
+{
+       [TestFixture]
+       public class ComponentConverterTests
+       {
+               [Test]
+               public void DataSetConversions ()
+               {
+                       TypeConverter converter = TypeDescriptor.GetConverter (typeof (DataSet));
+                       Assert.AreEqual (typeof (global::System.ComponentModel.ComponentConverter), converter != null ? converter.GetType () : null, "A1");
+
+                       DataSet ds = new DataSet ();
+                       string s = (string) converter.ConvertTo (null, CultureInfo.InvariantCulture, ds, typeof (string));
+                       Assert.AreEqual (String.Empty, s, "A2");
+
+                       object obj = converter.ConvertFrom (null, CultureInfo.InvariantCulture, s);
+                       Assert.IsNull (obj, "A3");
+               }
+       }
+}