Bug 58912 - Json.Net not working via Live Player
Summary: Json.Net not working via Live Player
Status: RESOLVED FIXED
Alias: None
Product: Live Player
Classification: Xamarin
Component: Mobile App (show other bugs)
Version: 1.0.439
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: James Montemagno [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-08-20 16:57 UTC by Martin Jørgensen
Modified: 2017-10-02 11:01 UTC (History)
1 user (show)

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


Attachments
Crash on Android & iOS null deserialization (281.86 KB, application/x-zip-compressed)
2017-08-25 17:40 UTC, James Montemagno [MSFT]
Details

Description Martin Jørgensen 2017-08-20 16:57:33 UTC
Json.Net not working in Live Player:
Android (Live Player 1.0.502) crashes app without any exceptions.
iOS (Live Player 1.0.439) deserializing IEnumerable returns null.

I have tested it in an app with shared code and another app without shared code.

When I build and deploy the code to a real Android device, it works.


Tested using the following code:

public class TypeA
{
  public int A;
  public string B;
}

try
{
  var in1 = "{\"A\":1,\"B\":\"Test1\"}";
  TypeA out1 = JsonConvert.DeserializeObject<TypeA>(in1);

  var in2 = "[{\"A\":1,\"B\":\"Test1\"},{\"A\":2,\"B\":\"Test2\"},{\"A\":3,\"B\":\"Test3\"}]";
  IEnumerable<TypeA> out2 = JsonConvert.DeserializeObject<IEnumerable<TypeA>>(in2);
}
catch (Exception ex)
{
}
Comment 1 James Montemagno [MSFT] 2017-08-25 17:40:33 UTC
I have verified the crash on Android on both Deserialize Object calls.

iOS Successfully executes: 
  TypeA out1 = JsonConvert.DeserializeObject<TypeA>(in1);

However IEnumerable deserialization does return null, which is a current known limitation of the reflection it uses.

I have added a small sample project as well to click the button and see it.
Comment 2 James Montemagno [MSFT] 2017-08-25 17:40:54 UTC
Created attachment 24424 [details]
Crash on Android & iOS null deserialization
Comment 3 Martin Jørgensen 2017-08-25 18:52:19 UTC
Thank you for confirming, that it is still an issue.

In V1.0.402 the following fix was announced: "Increase NuGet Support: Sqlite-net & Json.NET". I just hoped, that is was the case.

My App requires access to a list of json objects from a web service, so it seems like I will have to develop without using the Live Player - for now.

But I really, really like the idea of Live Player.

It is going to be great!
Comment 4 James Montemagno [MSFT] 2017-08-31 20:15:31 UTC
I would recommend developing with mock data with the Live Player. While it totally can and should be able to do this, the best approach for design type tools like the Live Player is some mock data. It will also speed up your process of using Live Run Current View.

Note You need to log in before you can comment on or make changes to this bug.