Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Enumerable.OrderBy does not work in reflection-free mode. #8302

Open
Thealexbarney opened this issue Sep 6, 2020 · 1 comment
Open

Enumerable.OrderBy does not work in reflection-free mode. #8302

Thealexbarney opened this issue Sep 6, 2020 · 1 comment
Milestone

Comments

@Thealexbarney
Copy link

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
@MichalStrehovsky
Copy link
Member

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.

<!-- Comparers don't currently work with reflection disabled. https://github.com/dotnet/corert/pull/7208 -->
<IlcArg Condition="$(IlcDisableReflection) == 'true'" Include="--removefeature:Comparers" />

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.

@MichalStrehovsky MichalStrehovsky added this to the Preview milestone Sep 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants