Announcement

Collapse
No announcement yet.

ToArray() broken on some IEnumerables

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • selinc
    started a topic ToArray() broken on some IEnumerables

    ToArray() broken on some IEnumerables

    I can't quite figure out the root cause of why its failing, but found this working and broken cases for ToArray() on IEnumerable.

    https://deck.net/a664ebec105b796041f8ab8ea6e496c0
        public static void Broken(string[] strings)
        {   
            var stringEnumerable = new string[]{"_"}.Concat(strings);
            var stringArray = stringEnumerable.ToArray();
        }
    
        public static void Works(string[] strings)
        {   
            var stringEnumerable = Enumerable.Repeat("_", 1).Concat(strings);
            var stringArray = stringEnumerable.ToArray();
        }
    Its strange that string[] breaks while Enumerable.Repeat side steps whatever the issue is-- Hopefully these two cases help track it down more easily.

  • geoffrey.mcgill
    replied
    Hi. Maybe this issue will be solved with the following PR:
    https://github.com/bridgedotnet/Bridge/pull/3818

    I have not tested to confirm, but it seems they are related.

    Leave a comment:


  • selinc
    replied
    Additionally this prevents you from calling ToArray() on an array to create a copy of that array.

    Leave a comment:


  • selinc
    replied
    Bump... Haven't heard anything back. Is there any status?

    [Edit]
    It appears the actual problem is that the Linq Concat extension improperly returns an Array type. It should return an IEnumerable<T> to match dotnet.
    Last edited by selinc; 2019-01-10 @ 09:54 PM. Reason: More information found.

    Leave a comment:


  • selinc
    replied
    Haven't heard from you guys. Just pinging you to see the status or if it is even in the system yet (usually I get a response within two days or so).
    Thanks

    Leave a comment:

Working...
X