Enumerable.OrderBy does not work in reflection-free mode.
Thealexbarney opened this issue · comments
Given this example code, the numbers should be printed in ascending order.
using System;
using System.Linq;
namespace test
{
class Program
{
static void Main(string[] args)
{
int[] unsorted = { 5, 257, 66, 6 };
foreach (int val in unsorted.OrderBy(x => x))
{
Console.WriteLine(val);
}
}
}
}
A default CoreRT build will print the sorted numbers.
5
6
66
257
However, the following is printed in reflection-free mode.
5
257
66
6
I would have to debug this, but it's possibly related to the the fact that we disable the default comparers logic in reflection free mode right now.
corert/src/BuildIntegration/Microsoft.NETCore.Native.targets
Lines 221 to 222 in e3f7bb5
Not quite sure why the fallback wouldn't work though.
Also the reasons why we had to disable them in the first place probably don't exist anymore, but enabling them will be a size regression. Comparer<Foo>.Default
is basically reflection right now.