<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>Json Work Item Rss Feed</title><link>http://www.codeplex.com/Json/WorkItem/List.aspx</link><description>Json Work Item Rss Description</description><item><title>Created Unassigned: enum's [JsonConvert] annotation ignored when enum is Dictionary&lt;&gt; key [24331]</title><link>http://json.codeplex.com/workitem/24331</link><description>More trouble with enums&amp;#33;  The converter is being ignored when the enum is a key in a dictionary. The code snippet below &amp;#40;A LINQPad snippet&amp;#41; should output&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#123; &amp;#39;baz&amp;#39;&amp;#58; &amp;#39;baz&amp;#39; &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;but instead outputs&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#123; &amp;#39;SerializeAsBaz&amp;#39;&amp;#58; &amp;#39;baz&amp;#39; &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;The enum is being correctly converted on the left-hand side, but not the right.&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;void Main&amp;#40;&amp;#41;&lt;br /&gt;&amp;#123;&lt;br /&gt;   &amp;#9;var d &amp;#61; new Dictionary&amp;#60;Foo,object&amp;#62;&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;d&amp;#91;Foo.SerializeAsBaz&amp;#93; &amp;#61; Foo.SerializeAsBaz&amp;#59;&lt;br /&gt;&amp;#9;newtonSerialize&amp;#40;d&amp;#41;.Dump&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;br /&gt;public static string newtonSerialize&amp;#40;object ob&amp;#41;&lt;br /&gt;&amp;#123;&lt;br /&gt;&amp;#9;var j &amp;#61; JsonSerializer.Create&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;StringBuilder sb &amp;#61; new StringBuilder&amp;#40;256&amp;#41;&amp;#59;&lt;br /&gt;    StringWriter sw &amp;#61; new StringWriter&amp;#40;sb, CultureInfo.InvariantCulture&amp;#41;&amp;#59;&lt;br /&gt;    using &amp;#40;JsonTextWriter jsonWriter &amp;#61; new JsonTextWriter&amp;#40;sw&amp;#41;&amp;#41;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        jsonWriter.Formatting &amp;#61; Newtonsoft.Json.Formatting.Indented&amp;#59;&lt;br /&gt;        jsonWriter.QuoteName &amp;#61; false&amp;#59;&lt;br /&gt;        jsonWriter.QuoteChar &amp;#61; &amp;#39;&amp;#92;&amp;#39;&amp;#39;&amp;#59;&lt;br /&gt;&lt;br /&gt;        j.Serialize&amp;#40;jsonWriter, ob&amp;#41;&amp;#59;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#9;return sw.ToString&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;#47;&amp;#47; Define other methods and classes here&lt;br /&gt;&amp;#91;JsonConverter&amp;#40;typeof&amp;#40;Newtonsoft.Json.Converters.StringEnumConverter&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;enum Foo &amp;#123;&lt;br /&gt;   &amp;#91;EnumMember&amp;#40;Value &amp;#61; &amp;#34;foo_bar&amp;#34;&amp;#41;&amp;#93; FooBar &amp;#61; 0x01,&lt;br /&gt;   Bat &amp;#61; 0x02,&lt;br /&gt;   &amp;#91;EnumMember&amp;#40;Value &amp;#61;&amp;#34;baz&amp;#34;&amp;#41;&amp;#93; SerializeAsBaz &amp;#61; 0x4,&lt;br /&gt;&amp;#125;&amp;#59;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;</description><author>pryankster</author><pubDate>Tue, 21 May 2013 23:24:14 GMT</pubDate><guid isPermaLink="false">Created Unassigned: enum's [JsonConvert] annotation ignored when enum is Dictionary&lt;&gt; key [24331] 20130521112414P</guid></item><item><title>Created Unassigned: Assembly Version Update? [24330]</title><link>http://json.codeplex.com/workitem/24330</link><description>Unsure if this is an actual issue&amp;#58;  The current version &amp;#40;5.0.5&amp;#41; appears to be set as 4.5.0.0 in the assembly.  Noticed this when attempting to resolve build warnings with another nuget package.&lt;br /&gt;&lt;br /&gt;The following has worked for us, entirely unchanged since 4.5.  Not sure if you want it updated.&lt;br /&gt;        &amp;#60;bindingRedirect oldVersion&amp;#61;&amp;#34;0.0.0.0-4.5.0.0&amp;#34; newVersion&amp;#61;&amp;#34;4.5.0.0&amp;#34; &amp;#47;&amp;#62;&lt;br /&gt;</description><author>sallgeud</author><pubDate>Tue, 21 May 2013 21:24:36 GMT</pubDate><guid isPermaLink="false">Created Unassigned: Assembly Version Update? [24330] 20130521092436P</guid></item><item><title>Created Unassigned: StringEnumConverter ignores [EnumMember] with [Flags] on enum [24329]</title><link>http://json.codeplex.com/workitem/24329</link><description>When the &amp;#91;Flags&amp;#93; attribute is applied to an enum, and the enum value to serialize is made up of more than one  flag value, the StringEnumConverter fails to respect &amp;#91;EnumMemberAttribute&amp;#93;.&lt;br /&gt;&lt;br /&gt;code below is from a LINQPad snippet&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;void Main&amp;#40;&amp;#41;&lt;br /&gt;&amp;#123;&lt;br /&gt;    List&amp;#60;Foo&amp;#62; lfoo &amp;#61; new List&amp;#60;Foo&amp;#62;&amp;#40;&amp;#41; &amp;#123; Foo.FooBar, Foo.Bat, Foo.SerializeAsBaz, Foo.Bat &amp;#124; Foo.SerializeAsBaz, Foo.FooBar&amp;#124;Foo.SerializeAsBaz&amp;#125;&amp;#59;&lt;br /&gt;&amp;#9;List&amp;#60;Bar&amp;#62; lbar &amp;#61; new List&amp;#60;Bar&amp;#62;&amp;#40;&amp;#41; &amp;#123; Bar.FooBar, Bar.Bat, Bar.SerializeAsBaz &amp;#125;&amp;#59;&lt;br /&gt; &lt;br /&gt;    lfoo.Dump&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;Test&amp;#40;&amp;#34;List&amp;#60;Foo&amp;#62; &amp;#40;bitmapped, string mapped with EnumMember&amp;#41;&amp;#34;,lfoo&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;lbar.Dump&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;Test&amp;#40;&amp;#34;List&amp;#60;Bar&amp;#62; &amp;#40;not bitmapped, string mapped with EnumMember&amp;#41;&amp;#34;, lbar&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;br /&gt;public static void Test&amp;#60;T&amp;#62;&amp;#40;string name, T ob&amp;#41;&lt;br /&gt;&amp;#123;&lt;br /&gt;&amp;#9;var jstr &amp;#61; newtonSerialize&amp;#40;ob&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&amp;#9;string.Format&amp;#40;&amp;#34;Serialized &amp;#123;0&amp;#125;&amp;#58; &amp;#123;1&amp;#125;&amp;#34;, name, jstr&amp;#41;.Dump&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;    &lt;br /&gt;&amp;#9;var new_list &amp;#61; JsonConvert.DeserializeObject&amp;#60;T&amp;#62;&amp;#40;jstr&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;string.Format&amp;#40;&amp;#34;Deserialize &amp;#123;0&amp;#125;&amp;#58;&amp;#34;, name&amp;#41;.Dump&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;new_list.Dump&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;br /&gt;public static string newtonSerialize&amp;#40;object ob&amp;#41;&lt;br /&gt;&amp;#123;&lt;br /&gt;&amp;#9;var j &amp;#61; JsonSerializer.Create&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;StringBuilder sb &amp;#61; new StringBuilder&amp;#40;256&amp;#41;&amp;#59;&lt;br /&gt;    StringWriter sw &amp;#61; new StringWriter&amp;#40;sb, CultureInfo.InvariantCulture&amp;#41;&amp;#59;&lt;br /&gt;    using &amp;#40;JsonTextWriter jsonWriter &amp;#61; new JsonTextWriter&amp;#40;sw&amp;#41;&amp;#41;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        jsonWriter.Formatting &amp;#61; Newtonsoft.Json.Formatting.Indented&amp;#59;&lt;br /&gt;        jsonWriter.QuoteName &amp;#61; false&amp;#59;&lt;br /&gt;        jsonWriter.QuoteChar &amp;#61; &amp;#39;&amp;#92;&amp;#39;&amp;#39;&amp;#59;&lt;br /&gt;&lt;br /&gt;        j.Serialize&amp;#40;jsonWriter, ob&amp;#41;&amp;#59;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#9;return sw.ToString&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;br /&gt;&amp;#47;&amp;#47; Define other methods and classes here&lt;br /&gt;&amp;#91;Flags&amp;#93;&lt;br /&gt;&amp;#91;JsonConverter&amp;#40;typeof&amp;#40;Newtonsoft.Json.Converters.StringEnumConverter&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;enum Foo &amp;#123;&lt;br /&gt;   &amp;#91;EnumMember&amp;#40;Value &amp;#61; &amp;#34;foo_bar&amp;#34;&amp;#41;&amp;#93; FooBar &amp;#61; 0x01,&lt;br /&gt;   Bat &amp;#61; 0x02,&lt;br /&gt;   &amp;#91;EnumMember&amp;#40;Value &amp;#61;&amp;#34;baz&amp;#34;&amp;#41;&amp;#93; SerializeAsBaz &amp;#61; 0x4,&lt;br /&gt;&amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;&amp;#91;JsonConverter&amp;#40;typeof&amp;#40;Newtonsoft.Json.Converters.StringEnumConverter&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;enum Bar &amp;#123;&lt;br /&gt;   &amp;#91;EnumMember&amp;#40;Value &amp;#61; &amp;#34;foo_bar&amp;#34;&amp;#41;&amp;#93; FooBar,&lt;br /&gt;   Bat,&lt;br /&gt;   &amp;#91;EnumMember&amp;#40;Value &amp;#61;&amp;#34;baz&amp;#34;&amp;#41;&amp;#93; SerializeAsBaz&lt;br /&gt;&amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;</description><author>pryankster</author><pubDate>Tue, 21 May 2013 07:01:56 GMT</pubDate><guid isPermaLink="false">Created Unassigned: StringEnumConverter ignores [EnumMember] with [Flags] on enum [24329] 20130521070156A</guid></item><item><title>Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328]</title><link>http://json.codeplex.com/workitem/24328</link><description>Sometimes I get nulls in arbitrary places&amp;#58;&lt;br /&gt;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;16472958&amp;#47;json-net-silently-ignores-circular-references-and-sets-arbitrary-links-in-the-ch&lt;br /&gt;&lt;br /&gt;And sometimes I just get exceptions. I thought JSON.NET was supposed to support reference loops when I turned reference tracking on&amp;#63;&lt;br /&gt;Comments: ** Comment from web user: ekolis ** &lt;p&gt;Well, I was half mistaken there. It did *serialize* the game state correctly; it simply failed to *deserialize* it correctly. That mistaken data was then placed into the player view. (My code is currently set to test serialization by saving and loading the game before creating the player view.) Still no idea why the simplified object graph is deserializing properly and the full one isn't.&lt;/p&gt;</description><author>ekolis</author><pubDate>Tue, 21 May 2013 05:58:49 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328] 20130521055849A</guid></item><item><title>Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328]</title><link>http://json.codeplex.com/workitem/24328</link><description>Sometimes I get nulls in arbitrary places&amp;#58;&lt;br /&gt;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;16472958&amp;#47;json-net-silently-ignores-circular-references-and-sets-arbitrary-links-in-the-ch&lt;br /&gt;&lt;br /&gt;And sometimes I just get exceptions. I thought JSON.NET was supposed to support reference loops when I turned reference tracking on&amp;#63;&lt;br /&gt;Comments: ** Comment from web user: ekolis ** &lt;p&gt;Oh, wait, it did serialize it! I was looking at the wrong file. I'm working on a strategy game, and I was looking at the player's view, which had some information taken out for fog of war purposes. The master game state file did have the properly serialized data. I guess the fog of war code removed the information I wanted from the player's view, even though it wasn't supposed to.&lt;/p&gt;</description><author>ekolis</author><pubDate>Tue, 21 May 2013 05:51:43 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328] 20130521055143A</guid></item><item><title>Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328]</title><link>http://json.codeplex.com/workitem/24328</link><description>Sometimes I get nulls in arbitrary places&amp;#58;&lt;br /&gt;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;16472958&amp;#47;json-net-silently-ignores-circular-references-and-sets-arbitrary-links-in-the-ch&lt;br /&gt;&lt;br /&gt;And sometimes I just get exceptions. I thought JSON.NET was supposed to support reference loops when I turned reference tracking on&amp;#63;&lt;br /&gt;Comments: ** Comment from web user: ekolis ** &lt;p&gt;Is there a limit to how deeply I can nest objects, perhaps? The loop only occurs after I'm already a few levels into the hierarchy.&lt;/p&gt;</description><author>ekolis</author><pubDate>Tue, 21 May 2013 05:48:44 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328] 20130521054844A</guid></item><item><title>Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328]</title><link>http://json.codeplex.com/workitem/24328</link><description>Sometimes I get nulls in arbitrary places&amp;#58;&lt;br /&gt;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;16472958&amp;#47;json-net-silently-ignores-circular-references-and-sets-arbitrary-links-in-the-ch&lt;br /&gt;&lt;br /&gt;And sometimes I just get exceptions. I thought JSON.NET was supposed to support reference loops when I turned reference tracking on&amp;#63;&lt;br /&gt;Comments: ** Comment from web user: ekolis ** &lt;p&gt;I have no idea what's going on. It works perfectly when I use a simplified version of my object graph, but when I use the actual code I'm working on, it breaks.&lt;/p&gt;</description><author>ekolis</author><pubDate>Tue, 21 May 2013 05:45:38 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328] 20130521054538A</guid></item><item><title>Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328]</title><link>http://json.codeplex.com/workitem/24328</link><description>Sometimes I get nulls in arbitrary places&amp;#58;&lt;br /&gt;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;16472958&amp;#47;json-net-silently-ignores-circular-references-and-sets-arbitrary-links-in-the-ch&lt;br /&gt;&lt;br /&gt;And sometimes I just get exceptions. I thought JSON.NET was supposed to support reference loops when I turned reference tracking on&amp;#63;&lt;br /&gt;Comments: ** Comment from web user: ekolis ** &lt;p&gt;I assume you mean repro? I'll see what I can do...&lt;/p&gt;</description><author>ekolis</author><pubDate>Tue, 21 May 2013 04:50:56 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328] 20130521045056A</guid></item><item><title>Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328]</title><link>http://json.codeplex.com/workitem/24328</link><description>Sometimes I get nulls in arbitrary places&amp;#58;&lt;br /&gt;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;16472958&amp;#47;json-net-silently-ignores-circular-references-and-sets-arbitrary-links-in-the-ch&lt;br /&gt;&lt;br /&gt;And sometimes I just get exceptions. I thought JSON.NET was supposed to support reference loops when I turned reference tracking on&amp;#63;&lt;br /&gt;Comments: ** Comment from web user: JamesNK ** &lt;p&gt;I need a simple repo.&lt;/p&gt;</description><author>JamesNK</author><pubDate>Tue, 21 May 2013 04:16:24 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328] 20130521041624A</guid></item><item><title>Created Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328]</title><link>http://json.codeplex.com/workitem/24328</link><description>Sometimes I get nulls in arbitrary places&amp;#58;&lt;br /&gt;&lt;br /&gt;http&amp;#58;&amp;#47;&amp;#47;stackoverflow.com&amp;#47;questions&amp;#47;16472958&amp;#47;json-net-silently-ignores-circular-references-and-sets-arbitrary-links-in-the-ch&lt;br /&gt;&lt;br /&gt;And sometimes I just get exceptions. I thought JSON.NET was supposed to support reference loops when I turned reference tracking on&amp;#63;&lt;br /&gt;</description><author>ekolis</author><pubDate>Tue, 21 May 2013 00:04:31 GMT</pubDate><guid isPermaLink="false">Created Unassigned: Reference loop handling doesn't work, even with reference tracking on [24328] 20130521120431A</guid></item><item><title>Closed Unassigned: Support Windows Phone 8 is needed [24323]</title><link>http://json.codeplex.com/workitem/24323</link><description>It currently only support Window Phone 7.1.&lt;br /&gt;&lt;br /&gt;Could you please make it also support Windows Phone 8 &amp;#63;&lt;br /&gt;&lt;br /&gt;The following error comes from NuGet&amp;#58;&lt;br /&gt;&lt;br /&gt;Successfully installed &amp;#39;Newtonsoft.Json 5.0.5&amp;#39;.&lt;br /&gt;Successfully uninstalled &amp;#39;Newtonsoft.Json 5.0.5&amp;#39;.&lt;br /&gt;Install failed. Rolling back...&lt;br /&gt;Could not install package &amp;#39;Newtonsoft.Json 5.0.5&amp;#39;. You are trying to install this package into a project that targets &amp;#39;WindowsPhone,Version&amp;#61;v8.0&amp;#39;, but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.&lt;br /&gt;&lt;br /&gt;Thanks.&lt;br /&gt;Comments: Log a bug with NuGet. There is a WP8 compatible portable class library that it should pick up.</description><author>JamesNK</author><pubDate>Mon, 20 May 2013 23:53:32 GMT</pubDate><guid isPermaLink="false">Closed Unassigned: Support Windows Phone 8 is needed [24323] 20130520115332P</guid></item><item><title>Created Unassigned: Support Windows Phone 8 is needed [24323]</title><link>http://json.codeplex.com/workitem/24323</link><description>It currently only support Window Phone 7.1.&lt;br /&gt;&lt;br /&gt;Could you please make it also support Windows Phone 8 &amp;#63;&lt;br /&gt;&lt;br /&gt;The following error comes from NuGet&amp;#58;&lt;br /&gt;&lt;br /&gt;Successfully installed &amp;#39;Newtonsoft.Json 5.0.5&amp;#39;.&lt;br /&gt;Successfully uninstalled &amp;#39;Newtonsoft.Json 5.0.5&amp;#39;.&lt;br /&gt;Install failed. Rolling back...&lt;br /&gt;Could not install package &amp;#39;Newtonsoft.Json 5.0.5&amp;#39;. You are trying to install this package into a project that targets &amp;#39;WindowsPhone,Version&amp;#61;v8.0&amp;#39;, but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.&lt;br /&gt;&lt;br /&gt;Thanks.&lt;br /&gt;</description><author>mingchen</author><pubDate>Mon, 20 May 2013 04:35:50 GMT</pubDate><guid isPermaLink="false">Created Unassigned: Support Windows Phone 8 is needed [24323] 20130520043550A</guid></item><item><title>Commented Issue: TypeConverter on Interfaces [24301]</title><link>http://json.codeplex.com/workitem/24301</link><description>In the current implementation of Json.NET, TypeConverters on interfaces and abstract classes are not handled properly &amp;#40;in my opinion&amp;#41;. If such a converter exists on an interface, the following code fragment in the ConvertUtils.Convert&amp;#40;object initialValue, CultureInfo culture, Type targetType&amp;#41; method will throw an exception&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#40;lines 410ff&amp;#41;&lt;br /&gt;     if &amp;#40;targetType.IsInterface&amp;#40;&amp;#41; &amp;#124;&amp;#124; targetType.IsGenericTypeDefinition&amp;#40;&amp;#41; &amp;#124;&amp;#124; targetType.IsAbstract&amp;#40;&amp;#41;&amp;#41;&lt;br /&gt;        throw new ArgumentException&amp;#40;&amp;#34;Target type &amp;#123;0&amp;#125; is not a value type or a non-abstract class.&amp;#34;.FormatWith&amp;#40;CultureInfo.InvariantCulture, targetType&amp;#41;, &amp;#34;targetType&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But in the next lines, the correct handling of the existing type converter takes place. So I would suggest to remove the above lines from the code. This does not break any unit tests and works &amp;#40;at least in my scenario it worked perfectly&amp;#41;.&lt;br /&gt;&lt;br /&gt;The case where no type converter is placed on an interface&amp;#47;abstract class is handled at the very end of the method.&lt;br /&gt;Comments: ** Comment from web user: macandy13 ** &lt;p&gt;Attached is a file that contains a sample that should cover the three cases where TypeConverter should be used store/restore interfaces, especially in combination with dictionaries.&lt;/p&gt;&lt;p&gt;I also adapted the code of Json.Net (version 5.0r5) to make the sample run. That required two changes, the one described above and another one that actually utilizes an associated TypeConverter to stringify dictionary keys.&lt;/p&gt;&lt;p&gt;It would be great if the two modifications could be part of the Json.NET deliver, since they do not break the unit tests but make TypeConverter handling more consistent (at least from my point of view).&lt;/p&gt;</description><author>macandy13</author><pubDate>Fri, 17 May 2013 12:38:32 GMT</pubDate><guid isPermaLink="false">Commented Issue: TypeConverter on Interfaces [24301] 20130517123832P</guid></item><item><title>Created Unassigned: [Win2003 &amp; Newtonsoft.Json.dll (.NET2.0version)]Build issue! [24316]</title><link>http://json.codeplex.com/workitem/24316</link><description>When build in VS there is a exception occurs which is as following&amp;#58;&lt;br /&gt;Missing compiler required member &amp;#39;System.Runtime.CompilerServices.ExtensionAttribute..ctor&amp;#39;&lt;br /&gt;&lt;br /&gt;Could you please explain what&amp;#39;s the reason of this issue&amp;#63; And please help me to resolve this issue&amp;#126;&lt;br /&gt;If you can not resolve this issue please let me know ASAP, Thx a lot &amp;#58;&amp;#41;&lt;br /&gt;</description><author>pangxiaoliang</author><pubDate>Fri, 17 May 2013 10:57:16 GMT</pubDate><guid isPermaLink="false">Created Unassigned: [Win2003 &amp; Newtonsoft.Json.dll (.NET2.0version)]Build issue! [24316] 20130517105716A</guid></item><item><title>Created Unassigned: Serialized Guid not converting in JToken [24314]</title><link>http://json.codeplex.com/workitem/24314</link><description>When serializing a Guid property using the BSONWriter, loading the result in a JObject does not allow me to get the property using the &amp;#34;Value&amp;#60;&amp;#62;&amp;#34; method. The JToken uses the Extensions.cs instead of the same method used by the BsonWriter.&lt;br /&gt;&lt;br /&gt;adding this to the Convert method in Extensions.cs&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;      else if &amp;#40;token is byte&amp;#91;&amp;#93; &amp;#38;&amp;#38; typeof&amp;#40;U&amp;#41;&amp;#61;&amp;#61; typeof&amp;#40;Guid&amp;#41;&amp;#41;&lt;br /&gt;          return &amp;#40;U&amp;#41;&amp;#40;object&amp;#41;&amp;#40;new Guid&amp;#40;&amp;#40;byte&amp;#91;&amp;#93;&amp;#41;&amp;#40;token as JValue&amp;#41;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;solves the problem.&lt;br /&gt;</description><author>kl_mallory</author><pubDate>Fri, 17 May 2013 04:53:13 GMT</pubDate><guid isPermaLink="false">Created Unassigned: Serialized Guid not converting in JToken [24314] 20130517045313A</guid></item><item><title>Commented Issue: Data loss when serializing a large decimal [24183]</title><link>http://json.codeplex.com/workitem/24183</link><description>Hi,&lt;br /&gt;&lt;br /&gt;I am trying to serialize a list of objects, which contains decimals some times. When I serialize it using BSON it usually works. In some cases, in particular when serializing large decimal values, the BSON serializer loses data.&lt;br /&gt;&lt;br /&gt;An example&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96; c&amp;#35;&lt;br /&gt;using Newtonsoft.Json&amp;#59;&lt;br /&gt;using Newtonsoft.Json.Bson&amp;#59;&lt;br /&gt;using System&amp;#59;&lt;br /&gt;using System.IO&amp;#59;&lt;br /&gt;&lt;br /&gt;namespace NewtonsoftJsonBugReport&lt;br /&gt;&amp;#123;&lt;br /&gt;    static class Program&lt;br /&gt;    &amp;#123;&lt;br /&gt;        class X&lt;br /&gt;        &amp;#123;&lt;br /&gt;            public X&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#123; &amp;#125;&lt;br /&gt;&lt;br /&gt;            public X&amp;#40;decimal d&amp;#41;&lt;br /&gt;            &amp;#123;&lt;br /&gt;                this.Data &amp;#61; d&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;&lt;br /&gt;            public decimal Data &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#47;&amp;#47;&amp;#47; &amp;#60;summary&amp;#62;&lt;br /&gt;        &amp;#47;&amp;#47;&amp;#47; The main entry point for the application.&lt;br /&gt;        &amp;#47;&amp;#47;&amp;#47; &amp;#60;&amp;#47;summary&amp;#62;&lt;br /&gt;        &amp;#91;STAThread&amp;#93;&lt;br /&gt;        static void Main&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            decimal d &amp;#61; 42386543286548654368345865241M&amp;#59;&lt;br /&gt;&lt;br /&gt;            byte&amp;#91;&amp;#93; output&amp;#59;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine&amp;#40;&amp;#34;Input value  &amp;#123;0&amp;#125;&amp;#34;, d&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;            JsonSerializer jsonSerializer &amp;#61; new JsonSerializer&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;            using &amp;#40;MemoryStream ms &amp;#61; new MemoryStream&amp;#40;&amp;#41;&amp;#41;&lt;br /&gt;            &amp;#123;&lt;br /&gt;                using &amp;#40;JsonWriter writer &amp;#61; new BsonWriter&amp;#40;ms&amp;#41;&amp;#41;&lt;br /&gt;                &amp;#123;&lt;br /&gt;                    jsonSerializer.Serialize&amp;#40;writer, new X&amp;#40;d&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;                &amp;#125;&lt;br /&gt;&lt;br /&gt;                output &amp;#61; ms.ToArray&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;&lt;br /&gt;            using &amp;#40;MemoryStream ms &amp;#61; new MemoryStream&amp;#40;output&amp;#41;&amp;#41;&lt;br /&gt;            &amp;#123;&lt;br /&gt;                using &amp;#40;JsonReader reader &amp;#61; new BsonReader&amp;#40;ms&amp;#41;&amp;#41;&lt;br /&gt;                &amp;#123;&lt;br /&gt;                    X x &amp;#61; jsonSerializer.Deserialize&amp;#60;X&amp;#62;&amp;#40;reader&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;                    d &amp;#61; x.Data&amp;#59;&lt;br /&gt;                &amp;#125;&lt;br /&gt;            &amp;#125;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine&amp;#40;&amp;#34;Output value &amp;#123;0&amp;#125;&amp;#34;, d&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;            Console.ReadKey&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;As you will see, the input is different from the output. This is obviously unwanted, but it also happens silently.&lt;br /&gt;&lt;br /&gt;The cause can be found in the BsonBinaryWriter &amp;#40;about line 114&amp;#41;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96; c&amp;#35;&lt;br /&gt;        case BsonType.Number&amp;#58;&lt;br /&gt;          &amp;#123;&lt;br /&gt;            BsonValue value &amp;#61; &amp;#40;BsonValue&amp;#41;t&amp;#59;&lt;br /&gt;            _writer.Write&amp;#40;Convert.ToDouble&amp;#40;value.Value, CultureInfo.InvariantCulture&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;          &amp;#125;&lt;br /&gt;          break&amp;#59;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;All numerics, except Int32 and Int64, are converted to Double, which causes the loss of data.&lt;br /&gt;&lt;br /&gt;My suggestion would be&amp;#58;&lt;br /&gt;1. To check if the converted data is the same as the input data. Like this, assuming that we are writing a Decimal&amp;#58;&lt;br /&gt;&lt;br /&gt;decimal originalValue &amp;#61; &amp;#40;decimal&amp;#41;value.Value&amp;#59;&lt;br /&gt;double d &amp;#61; Convert.ToDouble&amp;#40;value.Value, CultureInfo.InvariantCulture&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;decimal convertedValue &amp;#61; Convert.ToDecimal&amp;#40;d&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96; c&amp;#35;&lt;br /&gt;if &amp;#40;originalValue &amp;#33;&amp;#61; convertedValue&amp;#41;&lt;br /&gt;&amp;#123;&lt;br /&gt;    throw new Exception&amp;#40;&amp;#34;Cannot convert value to a lossless representative.&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;2. To include Decimal, Float and other types in BsonType so the writer can convert to and from the right type.&lt;br /&gt;&lt;br /&gt;Looking forward to your reply.&lt;br /&gt;Comments: ** Comment from web user: simon_laing ** &lt;p&gt;Hi James,&lt;/p&gt;&lt;p&gt;There appears to be an issue with deserialising decimals with numbers larger than Math.Abs(long.MinValue).&lt;br&gt;for example, decimal.MaxValue.&lt;/p&gt;&lt;p&gt;1. ConvertUtils.Int64TryParse() returns ParseResult.Overflow&lt;br&gt;2. JsonTextReader.ParseNumber() throws because the value is not an integer when trying to parse into a BigInteger.&lt;/p&gt;&lt;p&gt;If ConvertUtils.Int64TryParse() returned ParseResult.Invalid then an attempt would be made to parse the value into a decimal/Double and would succeed.&lt;/p&gt;&lt;p&gt;Decimal.MaxValue parsing works correctly in versions 4.5.4 and 4.5.6&lt;/p&gt;</description><author>simon_laing</author><pubDate>Thu, 16 May 2013 11:20:06 GMT</pubDate><guid isPermaLink="false">Commented Issue: Data loss when serializing a large decimal [24183] 20130516112006A</guid></item><item><title>Commented Issue: TypeConverter on Interfaces [24301]</title><link>http://json.codeplex.com/workitem/24301</link><description>In the current implementation of Json.NET, TypeConverters on interfaces and abstract classes are not handled properly &amp;#40;in my opinion&amp;#41;. If such a converter exists on an interface, the following code fragment in the ConvertUtils.Convert&amp;#40;object initialValue, CultureInfo culture, Type targetType&amp;#41; method will throw an exception&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#40;lines 410ff&amp;#41;&lt;br /&gt;     if &amp;#40;targetType.IsInterface&amp;#40;&amp;#41; &amp;#124;&amp;#124; targetType.IsGenericTypeDefinition&amp;#40;&amp;#41; &amp;#124;&amp;#124; targetType.IsAbstract&amp;#40;&amp;#41;&amp;#41;&lt;br /&gt;        throw new ArgumentException&amp;#40;&amp;#34;Target type &amp;#123;0&amp;#125; is not a value type or a non-abstract class.&amp;#34;.FormatWith&amp;#40;CultureInfo.InvariantCulture, targetType&amp;#41;, &amp;#34;targetType&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But in the next lines, the correct handling of the existing type converter takes place. So I would suggest to remove the above lines from the code. This does not break any unit tests and works &amp;#40;at least in my scenario it worked perfectly&amp;#41;.&lt;br /&gt;&lt;br /&gt;The case where no type converter is placed on an interface&amp;#47;abstract class is handled at the very end of the method.&lt;br /&gt;Comments: ** Comment from web user: JamesNK ** &lt;p&gt;Could you attach an example of the scenario that you think should work?&lt;/p&gt;</description><author>JamesNK</author><pubDate>Tue, 14 May 2013 23:50:14 GMT</pubDate><guid isPermaLink="false">Commented Issue: TypeConverter on Interfaces [24301] 20130514115014P</guid></item><item><title>Closed Issue: InvalidCastException when deserializing custom IConvertible [24285]</title><link>http://json.codeplex.com/workitem/24285</link><description>Since upgrading JSon.NET from 4.5 to 5.0.5 my custom value type &amp;#40;a mathematical &amp;#96;Ratio&amp;#60;T&amp;#62;&amp;#96; class that implements &amp;#96;IConvertible&amp;#96;&amp;#41; no longer deserializes successfully. Instead I get an &amp;#96;InvalidCastException&amp;#96;.&lt;br /&gt;&lt;br /&gt;The problem occurs because for example a &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; value is serialized as single number string if the ratio represents a whole number, whereas it is serialised as a fraction &amp;#40;for example 1&amp;#47;2&amp;#41; otherwise. When deserializing an integer source value into a &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; target value, the conversion procedure recognizes both the source value &amp;#40;&amp;#96;Int32&amp;#96; type&amp;#41; and the target value &amp;#40;&amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; type&amp;#41; as &amp;#96;IConvertible&amp;#96; and calls &amp;#96;Convert.ChangeType&amp;#40;intValue, typeof&amp;#40;Ratio&amp;#60;int&amp;#62;&amp;#41;, culture&amp;#41;&amp;#96;, causing an &amp;#96;InvalidCastException&amp;#96; because the &amp;#96;System.Int32&amp;#96; class doesn&amp;#39;t know how to convert to &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; values.&lt;br /&gt;&lt;br /&gt;For this reason &amp;#96;Convert.ChangeType&amp;#96; should not be relied on when deserialising values into &amp;#96;IConvertible&amp;#96; types that are non-system types.&lt;br /&gt;Comments: Thanks. Fixed</description><author>JamesNK</author><pubDate>Tue, 14 May 2013 23:22:45 GMT</pubDate><guid isPermaLink="false">Closed Issue: InvalidCastException when deserializing custom IConvertible [24285] 20130514112245P</guid></item><item><title>Commented Issue: InvalidCastException when deserializing custom IConvertible [24285]</title><link>http://json.codeplex.com/workitem/24285</link><description>Since upgrading JSon.NET from 4.5 to 5.0.5 my custom value type &amp;#40;a mathematical &amp;#96;Ratio&amp;#60;T&amp;#62;&amp;#96; class that implements &amp;#96;IConvertible&amp;#96;&amp;#41; no longer deserializes successfully. Instead I get an &amp;#96;InvalidCastException&amp;#96;.&lt;br /&gt;&lt;br /&gt;The problem occurs because for example a &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; value is serialized as single number string if the ratio represents a whole number, whereas it is serialised as a fraction &amp;#40;for example 1&amp;#47;2&amp;#41; otherwise. When deserializing an integer source value into a &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; target value, the conversion procedure recognizes both the source value &amp;#40;&amp;#96;Int32&amp;#96; type&amp;#41; and the target value &amp;#40;&amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; type&amp;#41; as &amp;#96;IConvertible&amp;#96; and calls &amp;#96;Convert.ChangeType&amp;#40;intValue, typeof&amp;#40;Ratio&amp;#60;int&amp;#62;&amp;#41;, culture&amp;#41;&amp;#96;, causing an &amp;#96;InvalidCastException&amp;#96; because the &amp;#96;System.Int32&amp;#96; class doesn&amp;#39;t know how to convert to &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; values.&lt;br /&gt;&lt;br /&gt;For this reason &amp;#96;Convert.ChangeType&amp;#96; should not be relied on when deserialising values into &amp;#96;IConvertible&amp;#96; types that are non-system types.&lt;br /&gt;Comments: ** Comment from web user: ggeurts ** &lt;p&gt;```&lt;br&gt;namespace JsonConvertible&lt;br&gt;{&lt;br&gt;	using System;&lt;br&gt;	using System.Globalization;&lt;br&gt;	using System.Runtime.Serialization;&lt;br&gt;	using Newtonsoft.Json;&lt;/p&gt;&lt;p&gt;	class Program&lt;br&gt;	{&lt;br&gt;		static void Main(string[] args)&lt;br&gt;		{&lt;br&gt;			var ratio = new Ratio(2, 1);&lt;br&gt;			var json = JsonConvert.SerializeObject(ratio);&lt;/p&gt;&lt;p&gt;			// Throws exception in Newtonsoft.Json 5.0.5&lt;br&gt;			var ratio2 = JsonConvert.DeserializeObject&amp;lt;Ratio&amp;gt;(json);&lt;br&gt;		}&lt;br&gt;	}&lt;/p&gt;&lt;p&gt;	public struct Ratio: IConvertible, IFormattable, ISerializable&lt;br&gt;	{&lt;br&gt;		private readonly int _numerator;&lt;br&gt;		private readonly int _denominator;&lt;/p&gt;&lt;p&gt;		public Ratio(int numerator, int denominator)&lt;br&gt;		{&lt;br&gt;			_numerator = numerator;&lt;br&gt;			_denominator = denominator;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		#region Properties&lt;/p&gt;&lt;p&gt;		public int Numerator&lt;br&gt;		{&lt;br&gt;			get { return _numerator; }&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public int Denominator&lt;br&gt;		{&lt;br&gt;			get { return _denominator; }&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public bool IsNan&lt;br&gt;		{&lt;br&gt;			get { return _denominator == 0; }&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		#endregion&lt;/p&gt;&lt;p&gt;		#region Serialization operations&lt;/p&gt;&lt;p&gt;		public Ratio(SerializationInfo info, StreamingContext context)&lt;br&gt;		{&lt;br&gt;			_numerator = info.GetInt32(&amp;quot;n&amp;quot;);&lt;br&gt;			_denominator = info.GetInt32(&amp;quot;d&amp;quot;);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public void GetObjectData(SerializationInfo info, StreamingContext context)&lt;br&gt;		{&lt;br&gt;			info.AddValue(&amp;quot;n&amp;quot;, _numerator);&lt;br&gt;			info.AddValue(&amp;quot;d&amp;quot;, _denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		#endregion&lt;/p&gt;&lt;p&gt;		#region IConvertible Members&lt;/p&gt;&lt;p&gt;		public TypeCode GetTypeCode()&lt;br&gt;		{&lt;br&gt;			return TypeCode.Object;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public bool ToBoolean(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return this._numerator == 0;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public byte ToByte(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return (byte)(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public char ToChar(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return Convert.ToChar(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public DateTime ToDateTime(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return Convert.ToDateTime(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public decimal ToDecimal(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return (decimal)this._numerator / this._denominator;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public double ToDouble(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return this._denominator == 0&lt;br&gt;				? double.NaN&lt;br&gt;				: (double)this._numerator / this._denominator;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public short ToInt16(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return (short)(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public int ToInt32(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return this._numerator / this._denominator;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public long ToInt64(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return this._numerator / this._denominator;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public sbyte ToSByte(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return (sbyte)(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public float ToSingle(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return this._denominator == 0&lt;br&gt;				? float.NaN&lt;br&gt;				: (float)this._numerator / this._denominator;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public string ToString(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return this._denominator == 1&lt;br&gt;				? this._numerator.ToString(provider)&lt;br&gt;				: this._numerator.ToString(provider) + &amp;quot;/&amp;quot; + this._denominator.ToString(provider);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public object ToType(Type conversionType, IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return Convert.ChangeType(ToDouble(provider), conversionType, provider);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public ushort ToUInt16(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return (ushort)(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public uint ToUInt32(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return (uint)(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public ulong ToUInt64(IFormatProvider provider)&lt;br&gt;		{&lt;br&gt;			return (ulong)(this._numerator / this._denominator);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		#endregion&lt;/p&gt;&lt;p&gt;		#region String operations&lt;/p&gt;&lt;p&gt;		public override string ToString()&lt;br&gt;		{&lt;br&gt;			return ToString(CultureInfo.InvariantCulture);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public string ToString(string format, IFormatProvider formatProvider)&lt;br&gt;		{&lt;br&gt;			return ToString(CultureInfo.InvariantCulture);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public static Ratio Parse(string input)&lt;br&gt;		{&lt;br&gt;			return Parse(input, CultureInfo.InvariantCulture);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public static Ratio Parse(string input, IFormatProvider formatProvider)&lt;br&gt;		{&lt;br&gt;			Ratio result;&lt;br&gt;			if (!TryParse(input, formatProvider, out result))&lt;br&gt;			{&lt;br&gt;				throw new FormatException(&lt;br&gt;					string.Format(&lt;br&gt;						CultureInfo.InvariantCulture, &lt;br&gt;						&amp;quot;Text '{0}' is invalid text representation of ratio&amp;quot;, &lt;br&gt;						input));&lt;br&gt;			}&lt;br&gt;			return result;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public static bool TryParse(string input, out Ratio result)&lt;br&gt;		{&lt;br&gt;			return TryParse(input, CultureInfo.InvariantCulture, out result);&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		public static bool TryParse(string input, IFormatProvider formatProvider, out Ratio result)&lt;br&gt;		{&lt;br&gt;			if (input != null)&lt;br&gt;			{&lt;br&gt;				var fractionIndex = input.IndexOf('/');&lt;/p&gt;&lt;p&gt;				int numerator;&lt;br&gt;				if (fractionIndex &amp;lt; 0)&lt;br&gt;				{&lt;br&gt;					if (int.TryParse(input, NumberStyles.Integer, formatProvider, out numerator))&lt;br&gt;					{&lt;br&gt;						result = new Ratio(numerator, 1);&lt;br&gt;						return true;&lt;br&gt;					}&lt;br&gt;				}&lt;br&gt;				else&lt;br&gt;				{&lt;br&gt;					int denominator;&lt;br&gt;					if (int.TryParse(input.Substring(0, fractionIndex), NumberStyles.Integer, formatProvider, out numerator) &amp;amp;&amp;amp;&lt;br&gt;						int.TryParse(input.Substring(fractionIndex + 1), NumberStyles.Integer, formatProvider, out denominator))&lt;br&gt;					{&lt;br&gt;						result = new Ratio(numerator, denominator);&lt;br&gt;						return true;&lt;br&gt;					}&lt;br&gt;				}&lt;br&gt;			}&lt;/p&gt;&lt;p&gt;			result = default(Ratio);&lt;br&gt;			return false;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		#endregion&lt;br&gt;	}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;```&lt;/p&gt;</description><author>ggeurts</author><pubDate>Tue, 14 May 2013 12:05:14 GMT</pubDate><guid isPermaLink="false">Commented Issue: InvalidCastException when deserializing custom IConvertible [24285] 20130514120514P</guid></item><item><title>Commented Issue: InvalidCastException when deserializing custom IConvertible [24285]</title><link>http://json.codeplex.com/workitem/24285</link><description>Since upgrading JSon.NET from 4.5 to 5.0.5 my custom value type &amp;#40;a mathematical &amp;#96;Ratio&amp;#60;T&amp;#62;&amp;#96; class that implements &amp;#96;IConvertible&amp;#96;&amp;#41; no longer deserializes successfully. Instead I get an &amp;#96;InvalidCastException&amp;#96;.&lt;br /&gt;&lt;br /&gt;The problem occurs because for example a &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; value is serialized as single number string if the ratio represents a whole number, whereas it is serialised as a fraction &amp;#40;for example 1&amp;#47;2&amp;#41; otherwise. When deserializing an integer source value into a &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; target value, the conversion procedure recognizes both the source value &amp;#40;&amp;#96;Int32&amp;#96; type&amp;#41; and the target value &amp;#40;&amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; type&amp;#41; as &amp;#96;IConvertible&amp;#96; and calls &amp;#96;Convert.ChangeType&amp;#40;intValue, typeof&amp;#40;Ratio&amp;#60;int&amp;#62;&amp;#41;, culture&amp;#41;&amp;#96;, causing an &amp;#96;InvalidCastException&amp;#96; because the &amp;#96;System.Int32&amp;#96; class doesn&amp;#39;t know how to convert to &amp;#96;Ratio&amp;#60;int&amp;#62;&amp;#96; values.&lt;br /&gt;&lt;br /&gt;For this reason &amp;#96;Convert.ChangeType&amp;#96; should not be relied on when deserialising values into &amp;#96;IConvertible&amp;#96; types that are non-system types.&lt;br /&gt;Comments: ** Comment from web user: ggeurts ** &lt;p&gt;My unit tests pass when using version 4.5.11, but fail under 5.0.5. I will try to get some sample code to illustrate the issue.&lt;/p&gt;</description><author>ggeurts</author><pubDate>Tue, 14 May 2013 10:32:44 GMT</pubDate><guid isPermaLink="false">Commented Issue: InvalidCastException when deserializing custom IConvertible [24285] 20130514103244A</guid></item></channel></rss>