Tag: XAMARINE

MakeGenericMethod / MakeGenericType在Xamarin.iOS上

我试图弄清楚从Xamarin部署iOS时限制的真正含义。 http://developer.xamarin.com/guides/ios/advanced_topics/limitations/ 我的印象是,你没有JIT,因此任何MakeGenericMethod或MakeGenericType都不会工作,因为这将需要JIT编译。 另外我明白,当在模拟器上运行时,这些限制不适用,因为模拟器没有在完整的AOT(前面的时间)模式下运行。 设置我的Mac后,我可以部署到我的手机,除了以下testing失败时,在实际设备(iPhone)上运行。 [Test] public void InvokeGenericMethod() { var method = typeof(SampleTests).GetMethod ("SomeGenericMethod"); var closedMethod = method.MakeGenericMethod (GetTypeArgument()); closedMethod.Invoke (null, new object[]{42}); } public static void SomeGenericMethod<T>(T value) { } private Type GetTypeArgument() { return typeof(int); } 事情是成功完成,我不明白为什么。 这个代码不需要JIT编译吗? 为了“让它rest”,我也用MakeGenericType做了testing。 [Test] public void InvokeGenericType() { var type = typeof(SomeGenericClass<>).MakeGenericType (typeof(string)); var instance = […]