Add DateTimeOffsetConverter to the default converters list.
authorSergey Odinokov <odinserj@gmail.com>
Mon, 8 Dec 2014 18:59:00 +0000 (21:59 +0300)
committerSergey Odinokov <odinserj@gmail.com>
Mon, 8 Dec 2014 18:59:00 +0000 (21:59 +0300)
This is the fix for https://bugzilla.xamarin.com/show_bug.cgi?id=25158

Current implementation does not contain the DateTimeOffsetConverter
in the list of default converters. This cause NotSupportedException
to be thrown when trying to serialize/deserialize DateTimeOffset
values to/from strings.

In .NET Framework implementation this class is added to such a list.

mcs/class/System/System.ComponentModel/TypeDescriptor.cs
mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs

index df7f55bcecfaca781ccfb380b566f65f53b447fd..9992eae79b7c227aac84d23602a0c1ec567e123d 100644 (file)
@@ -409,6 +409,7 @@ public sealed class TypeDescriptor
                                defaultConverters.Add (new DictionaryEntry (typeof (Array), typeof (ArrayConverter)));
                                defaultConverters.Add (new DictionaryEntry (typeof (CultureInfo), typeof (CultureInfoConverter)));
                                defaultConverters.Add (new DictionaryEntry (typeof (DateTime), typeof (DateTimeConverter)));
+                               defaultConverters.Add (new DictionaryEntry (typeof (DateTimeOffset), typeof (DateTimeOffsetConverter)));
                                defaultConverters.Add (new DictionaryEntry (typeof (Guid), typeof (GuidConverter)));
                                defaultConverters.Add (new DictionaryEntry (typeof (TimeSpan), typeof (TimeSpanConverter)));
                                defaultConverters.Add (new DictionaryEntry (typeof (ICollection), typeof (CollectionConverter)));
index a09776a9c00b41810928d26ee0e118948744c9de..c44f74dbaf3066a33b8d593ca10f2ea4ad26448a 100644 (file)
@@ -1244,6 +1244,7 @@ namespace MonoTests.System.ComponentModel
                        Assert.IsTrue (TypeDescriptor.GetConverter (new Component()) is ComponentConverter, "#30");
 #endif
                        Assert.AreEqual (typeof (NullableConverter), TypeDescriptor.GetConverter (typeof (int?)).GetType (), "#31");
+                       Assert.AreEqual (typeof (DateTimeOffsetConverter), TypeDescriptor.GetConverter (typeof (DateTimeOffset)).GetType (), "#32");
                }
                
                [Test]