I'm experiencing one of these annoying and strange behaviors which differs between Debug and Release mode. So, we're on UWP 10.0.10586, using JSON.NET 7.0.1
I've a model class that looks like this:
[JsonObject]
public class RootObject
{
[JsonProperty]
public Profile ProfileInfo { get; set; } = new Profile();
[JsonProperty]
public ImmutableList<Info> AdditionalInfo { get; set; } = ImmutableList.Create<Info>();
}
Then I try to deserialize a json:
var rootObject = JsonConvert.DeserializeObject<RootObject>(json);
This works perfectly in Debug mode, but doesn't deserialize AdditionalInfo when in Release mode (the list is null).
It also works if I use IEnumerable or IList instead of ImmutableList, but I wonder if there's a reason for this behavior or if is maybe a JSON.NET bug.
Most likely you are hitting one of the runtime exceptions from .NET Native. To properly diagnose this I'd recommend enabling .NET Native compilation for the DEBUG configuration of your project (Project properties > BUILD > Enable .Net Native checkbox). Then, set your debugger to stop on first chance exceptions.
Now when you run you'll probably see a MissingMetadataException or somethign about serialization but because you're in DEBUG you'll get decent exception strings. If you can move to Update 1, the messages are a bit better. Most likely you'll need to add something to your Default.rd.xml file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With