Felix
Felix

Reputation: 1384

Is there any documentation for ServiceStack.Text.JSConfig with regard to MonoTouch AOT helpers?

Is there any documentation for ServiceStack.Text.JSConfig with regard to MonoTouch AOT helpers?

I Found this... ServiceStack JIT Error on MonoTouch and I've had a look at the code but there are no comments and frankly it is a bit mysterious.

From my understanding of the AOT process all one needs to do to make sure a type/method is emitted is to have that type/method in one's source where the compiler thinks it may be used/called. It is not necessary to actually use/call anything at run time. The whole point of AOT is that it is a compile-time process. Consequently putting the use/call inside a method that is not used will work as long as the optimizer does not remove it.

I've been trying to use ServiceStack.Text.JsConfig.RegisterTypeForAot(); (in an unused method) to cure my AOT issues but have run into other weird issues when I have too many calls to it. See other question...

Calling ServiceStack.Text.JsConfig.RegisterTypeForAot<T>(); with MonoTouch causes SIGSEGV on startup on device

Could I maybe be using the RegisterTypeForAot() method wrongly? What do the other methods do? RegisterForAot() and InitAot()

Upvotes: 4

Views: 977

Answers (1)

mythz
mythz

Reputation: 143359

There is no documentation about JsConfig.InitForAot() other than what's already in-line in the JsConfig, i.e:

Provide hint to MonoTouch AOT compiler to pre-compile generic classes for all your DTOs. Just needs to be called once in a static constructor.

You should only have to call the JsConfig.InitForAot() stub and a JsConfig.RegisterTypeForAot<T>() for each type to let the MonoTouch compiler know what generic code needs to be pre-generated ahead of time so that all the code is available for generic reflection. If you run into a problem submit a small stand-alone test case with the issue on the GitHub project issues so we can see if there are any work around that can be done.

Upvotes: 1

Related Questions