Bug 20082 - C# Dynamic Support for Json.Net's JObject
Summary: C# Dynamic Support for Json.Net's JObject
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime (show other bugs)
Version: 7.2.2
Hardware: Macintosh Mac OS
: Normal enhancement
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-05-28 00:55 UTC by Rodja Trappe
Modified: 2014-05-28 12:38 UTC (History)
3 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 for Bug 20082 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Rodja Trappe 2014-05-28 00:55:40 UTC
Since version 4.0 Json.Net supports dynamic access to an JObject:

    dynamic d = JObject.Parse("{number:1000, str:'string', array: [1,2,3,4,5,6]}");

    Console.WriteLine(d.number);
    Console.WriteLine(d.str);
    Console.WriteLine(d.array.Count);

It would be great to have iOS support for this. However, the dynamic support in Xamarin.iOS 7.2.2 is limited to anonymous types. The above code results in an RuntimeBinderException:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: `Newtonsoft.Json.Linq.JObject' does not contain a definition for `number'
  at Microsoft.Scripting.Interpreter.ThrowInstruction.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00027] in /Developer/MonoTouch/Source/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ControlFlowInstructions.cs:505
  at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0001b] in /Developer/MonoTouch/Source/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs:126
Comment 1 Shruti 2014-05-28 07:59:59 UTC
I have created a sample iOS project and added above code written in description section. I am able to reproduce this issue at runtime.

ScreenCast regarding issue : http://screencast.com/t/iyXeQcRJuM54

Exception Log : https://gist.github.com/saurabh360/6c670267c8057b7d595d

Environment Info :
Xamarin.iOS
Version: 7.2.2.2 (Enterprise Edition)
Hash: db4427f
Branch: 
Build date: 2014-04-22 12:49:14-0400