Bug 25158 - TypeDescriptor.GetConverter(typeof(DateTimeOffset)) do not return DateTimeOffsetConverter
Summary: TypeDescriptor.GetConverter(typeof(DateTimeOffset)) do not return DateTimeOff...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-12-08 13:51 UTC by Sergey Odinokov
Modified: 2014-12-09 08:23 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Sergey Odinokov 2014-12-08 13:51:13 UTC
Instead, it returns the default converter. The following test will fail on Mono, but will pass on .NET Framework:

    Assert.AreEqual (
        typeof (DateTimeOffsetConverter), 
        TypeDescriptor.GetConverter (typeof (DateTimeOffset)).GetType ());

The problem is that the `DateTimeOffsetConverter` class is not being registered in the list of default converters:
https://github.com/mono/mono/blob/master/mcs/class/System/System.ComponentModel/TypeDescriptor.cs#L411

But it is registered in such a list in .NET Framework as we can see from ReferenceSource site:
http://referencesource.microsoft.com/#System/compmod/system/componentmodel/ReflectTypeDescriptionProvider.cs,136

The problem causes `NotSupportedException` to be thrown when trying to serialize/deserialize `DateTimeOffset` values to/from string.
Comment 1 Marek Safar 2014-12-09 08:23:10 UTC
Fixed in master