Bug 25808 - DataContractJsonSerializer cannot deserialize array to IEnumerable<T>
Summary: DataContractJsonSerializer cannot deserialize array to IEnumerable<T>
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 5.1
Hardware: PC Windows
: --- normal
Target Milestone: 5.1
Assignee: marcos.henrich
Depends on:
Reported: 2015-01-07 19:12 UTC by Morten Nielsen
Modified: 2015-05-07 09:54 UTC (History)
7 users (show)

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 Developer Community or GitHub 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:

Description Morten Nielsen 2015-01-07 19:12:01 UTC
The following class cannot be deserialized:
        public class TestContract
            public IEnumerable<string> items { get; set; }
I'm using the following code:

   string json = "{\"items\":[\"item1\",\"item2\"]}";
   using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
       DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(TestContract));
       var result = (TestContract)jsonSerializer.ReadObject(stream);

If I change the data member to be string[] it works. Note that the IEnumerable<string> works in .NET 4.5 (Desktop,store,phone).
Comment 1 Rodrigo Kumpera 2015-01-16 12:13:18 UTC
Hi Marcos,

Can you work on this over the next couple of weeks?
Comment 2 Zoltan Varga 2015-01-16 14:12:16 UTC
Fixed in mono master ba6d6d74cdaa50d60b28b1ea3c5617e277dae714.
Comment 3 Ram Chandra 2015-05-07 09:54:12 UTC
I have checked this issue on both OS X and windows with following builds and I am able to reproduce this issue.

OS X Environment Info:
OS X: 10.10.3
XS:  5.9.1 (build 2)
>Screencast: http://www.screencast.com/t/yeQwkznFjb

Windows Environment Info:
Windows 8.1
VS: 2013
>Screencast: http://www.screencast.com/t/VZ3QlHaywujt

To verify this issue I have checked this issue with following builds:

OS X Environment Info:
OS X: 10.10.3
XS:  5.9.1 (build 2)
Screencast: http://www.screencast.com/t/WZLph5ZaCvJ

Windows Environment Info: 
Windows 8.1
XVS:  3.11.538
VS: 2013
Screencast: http://www.screencast.com/t/dLrZoTTPG

Now, DataContractJsonSerializer able to deserialize array to IEnumerable<T>.

This issue has been fixed. Hence I am closing this issue.