Bug 19287 - JavaScriptSerializer deserializes nullable enum as always null
Summary: JavaScriptSerializer deserializes nullable enum as always null
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
Depends on:
Reported: 2014-04-24 15:53 UTC by Ole Hyldahl Tolshave
Modified: 2014-06-04 07:12 UTC (History)
2 users (show)

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

Console program reproducing the error (690 bytes, text/plain)
2014-04-24 15:57 UTC, Ole Hyldahl Tolshave

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:

Description Ole Hyldahl Tolshave 2014-04-24 15:53:25 UTC

Comment 1 Ole Hyldahl Tolshave 2014-04-24 15:57:08 UTC
Created attachment 6651 [details]
Console program reproducing the error
Comment 2 Ole Hyldahl Tolshave 2014-04-24 16:01:56 UTC
(Sorry for making multiple comments - Bugzilla seems quite eager to post before I am ready :-().

The attached C# console program can be built and run like this:
$ mcs DeserializeNullableEnum.cs /out:DeserializeNullableEnum.exe -r:System.Web.Extensions
$ mono DeserializeNullableEnum.exe
EnumValue before serialize: 'A', EnumValue after serialize: ''

On windows using .NET the output is (as expected):
EnumValue before serialize: 'A', EnumValue after serialize: 'A'

If the enum is made non-nullable, Mono works as expected. Also if the json is changed to this:
{"EnumValue":"1"}   # Note the quotes
then mono deserializes the nullable enum correctly.
Comment 3 marcos.henrich 2014-06-04 06:28:53 UTC
Hi Ole,

Thank you for the detailed bug report.

The pull request for this issue can be found in the link below.
link below
Comment 4 marcos.henrich 2014-06-04 06:29:31 UTC
Comment 5 marcos.henrich 2014-06-04 07:12:46 UTC
Fixed in master e28d8783c5d06d8132768fa3b482aa8b71ca2cdd.