Xamarin Introduces C# Async for iOS and Android
Xamarin has released a preview of their async-enabled libraries for iOS and Android development. This work is based heavily on Microsoft’s .NET 4.5, which was released late last year as part of Visual Studio 2012. Xamarin is the new name for the development platforms previously known as MonoTouch and Mono for Android.
As part of the Xamarin 2.0 initiative, the mobile platforms have adopted the class libraries found in Mono and .NET. Previously MonoTouch and Mono for Android were restricted to a subset based on Silverlight/Moonlight. Rodrigo Kumpera writes,
While asynchronicity is the main theme of this release, we also pack two years of improvements to the Mono runtime spread over more than 7,000 individual commits that are now available to Android, Mac and iOS users.
This release also brings with it improvements to the iOS batch compiler. Unlike most other platforms, iOS doesn’t allow for JIT-compiled code. This has led to problems with dynamically invoked code, especially where generics are involved.
On iOS we now generate “shareable code” for value types, a truly revolutionary innovation in code generation technology. In practical terms this means that a whole range of code that previously crashed with a “Attempting to JIT compile method” now works. While we still provide the high-performance, and fine-tuned generic code that we can infer –for example direct calls to a method Foo<T>(T x)– we generate a value-type shared version of Foo<T>(T x) that can be used in dynamic cases that previously failed. What was once a dream, is now a reality.
Currently Microsoft’s .NET own JIT compiler doesn’t have this capability. While it will share one method for all reference-types, a generic method has to be re-compiled for each distinct value type.
Variance and Contravariance support, introduced in .NET 4.0, has also found its way into the Xamarin platform.
Doc List Oct 25, 2014