I get the following error on my iOS device:
ExecutionEngineException: attempted by the JIT compilation method 'System.Linq.OrderedEnumerable 1<System.Collections.Generic.KeyValuePair 2>: GetEnumerator ()' while working with -aot-only.
I am using Unity3D and I know that the error is caused by LINQ expressions having problems with order value types when compiling Unity on iOS. Because (I think) that the expression is trying to use reflection to create a new type that implements the IComparer <TKey> interface. This will work for reference types, but not for value types for iOS Unity builds.
So, I thought that since I know in this situation, I am always trying to order a collection of ints. So that I can get around the generic ICompare <TKey> and just create my own custom mapper.
public class IntCompare : Comparer<int> { public override int Compare (int x, int y) { return x - y; } }
However, using OrderBy still gives me an error. I do not understand why my method does not work?
My expression:
OptimizeMaxCommitList(members .OrderBy((memberid) => memberid.Value, new IntCompare()) .Skip(1) .ToDictionary(pair => pair.Key, pair => pair.Value) ,maxCommit);
MichaelTaylor3D
source share