OrderBy and iOS gives JIT error?

I am trying to reorder an dictionary by using this line:

var orderedPairs = myturn.OrderBy(pair => pair.Value.Get<string>("lastMoveTime")).Select(pair => pair.Value);

It works perfectly in the editor but when compiling to iOS I get this error:

ExecutionEngineException: Attempting to JIT compile method ‘System.Linq.OrderedEnumerable1<System.Collections.Generic.KeyValuePair2<string, Parse.ParseObject>>:GetEnumerator ()’ while running with --aot-only.

How do I get passed this? Any ideas anyone?

Any help is appreciated and thanks in advance.

Generally speaking, iOS has the most troubles if you have a generic method/class with a value type parameter. So the whole linq library is a minefield of JIT compile errors. (Recently I used Enum.GetValues(typeof(T)).Cast().ToArray(), guess what, ToArray() did throw a JIT error because IEnumerable.ToArray() didn’t work for it although it works fine for a lot of other cases)

For the case OrderBy our company wrote our own extension method that is compatible with AoT.

I also ended up making a workaround:

List<ParseObject> myturnList = new List<ParseObject>(myturn.Values);
myturnList.Sort((e1,e2) => e1.Get<string>("lastMoveTime").CompareTo(e2.Get<string>("lastMoveTime")));

Thanks for your input though :slight_smile: