Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force Monotouch AOT Compiler to see a nested generic method?

I've had to jump through hoops, but I've almost managed to get ServiceStack working on iOS with Monotouch in my project. One runtime JIT exception is holding out:

System.ExecutionEngineException: Attempting to JIT compile method 'ServiceStack.Text.Json.JsonTypeSerializer:GetWriteFn<int> ()' while running with --aot-only. 

The offending code is quite simple:

   internal WriteObjectDelegate GetWriteFn<T>()
    {
        return JsonWriter<T>.WriteFn();
    }

As a test, I modified the SS code to make the internal methods and types public and included the following in the startup code of my project (to actually get called).

var ick = ServiceStack.Text.Json.JsonWriter<int>.WriteFn();
var erk = ServiceStack.Text.Json.JsonTypeSerializer.Instance.GetWriteFn<int>();

This still doesn't alert the AOT for some reason, I get the exception when the code above executes! Is this because the generic parameter is a value type? Or is it because these are static classes and methods? How can I force Monotouch to AOT the methods above?

The SS code in question is in JsonTypeSerializer.cs and JsonWriter.Generic.cs at: https://github.com/ServiceStack/ServiceStack.Text/tree/master/src/ServiceStack.Text/Json

like image 626
Felix Avatar asked Dec 11 '12 23:12

Felix


1 Answers

There are some generic limitations in monotouch now. I think you should check your code to one of them.

like image 95
gleb.kudr Avatar answered Oct 22 '22 15:10

gleb.kudr