Bug 37144 - Nullable decimals can't be serialised but nullable doubles can
Summary: Nullable decimals can't be serialised but nullable doubles can
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 9.4 (iOS 9.2)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2015-12-18 12:19 UTC by Matt Jones
Modified: 2017-09-11 10:58 UTC (History)
5 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 Matt Jones 2015-12-18 12:19:39 UTC
DataContractJsonSerializer.WriteObject throws a JIT exception when trying to serialise types that contain nullable decimals. Nullable doubles are fine.

This is a recently introduced problem, I'd guess at the last couple of updates (the move to Mono 4.20?).

This does not happen in 32-bit mode - only when building for ARM64.

To recreate it use something like this:

public class DecimalModel1 { public decimal? test; }
public class DecimalModel2 { public decimal test; }
public class DoubleModel   { public double? test; }

var ser1=new DataContractJsonSerializer(typeof(DecimalModel1));
var ser2=new DataContractJsonSerializer(typeof(DecimalModel2));
var ser3=new DataContractJsonSerializer(typeof(DoubleModel));

var stream=new MemoryStream();

var m1=new DecimalModel1() { test=2.59m; }
var m2=new DecimalModel2() { test=2.59m; }
var m3=new DoubleModel()   { test=2.59; }

ser3.WriteObject(stream,m3);   // this works
ser2.WriteObject(stream,m2);   // this works too
ser1.WriteObject(stream,m1);   // this will throw an exception
Comment 1 Rodrigo Kumpera 2015-12-18 18:55:37 UTC
Hey Marcos,

Could you take a look at this one?
Comment 2 Zoltan Varga 2015-12-18 21:14:46 UTC
This is probably a dup of:
Comment 3 Rodrigo Kumpera 2017-02-07 21:26:34 UTC
Shipping to the BCL team
Comment 4 Marek Safar 2017-09-11 10:58:20 UTC
I cannot reproduce the issue with recent version