'How Json.Net/NewtonsoftJson decides on how to serialize/deserialize depending on platform AOT or JIT

I'm profiling newtonsoft json inside unity, on my android device with 2 different scripting backend, Mono which supports IL Emit or in another words, code generation. But also IL2CPP, which does not support code generation. What Im benchmarking is, serialization and deserialization of a simple reference type with a single public field. With properties (not fields) I know that we could take advantage of Delegate.CreateDelegate (event in AOT platfoorms) giving the PropertyInfo, but the same is not true for fields, since there are no GetterMethod or SetterMethod. So, what Im thinking is that Newtonsoft json was taking a look on which platform is running, so for example, if platform supports IL Emit, then, emit a getter and setter for the field, if not, fallback to reflection, but I got the same results on my android benchmark for Mono and IL2CPP. So I would like to understand why I got the same result, reflection is not only being used as fallback? Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source