[Mono-bugs] [Bug 497720] System.Collections.Generic.KeyCollection.CopyTo(TKey [] array, int arrayIndex) behaves different on Mono / .NET

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Apr 23 14:08:00 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=497720

User jonas.larsson at manodo.se added comment
http://bugzilla.novell.com/show_bug.cgi?id=497720#c3





--- Comment #3 from Jonas Larsson <jonas.larsson at manodo.se>  2009-04-23 12:07:59 MDT ---
It's so obvious when you say it. I'm embarrassed. I actually thought I was
helping by being so specific. I was about to post patches, but I won't now.
Lesson learned the hard way :-( I will shape up in the future.


Test case:


using System.Collections.Generic;

using System;



class Program

{

  static void Main(string[] args)

  {

    SortedDictionary<int, int> dict = new SortedDictionary<int, int>();



    try

    {

      int[] keysArray = new int[dict.Count];

      dict.Keys.CopyTo(keysArray, 0);

      Console.Out.WriteLine("No error copying the keys");

    }

    catch (Exception ex)

    {

      Console.Error.WriteLine("Copy keys exception : " +
ex.GetType().FullName); 

    }



     try

     {

       int[] valuesArray = new int[dict.Count];

       dict.Values.CopyTo(valuesArray, 0);

       Console.Out.WriteLine("No error copying the values");

     }

     catch (Exception ex)

     {

        Console.Error.WriteLine("Copy values exception : " +
ex.GetType().FullName);

     }

  }

}




Run on Mono:
$ mono Test.exe
Copy keys exception : System.ArgumentOutOfRangeException
Copy values exception : System.ArgumentOutOfRangeException

Run on .NET
Copy keys exception : System.ArgumentOutOfRangeException
Copy values exception : System.ArgumentOutOfRangeException



I really hope this can be of value to you. I have already fixed it myself, but
can't submit the patches. 

Thanks for your great efforts!

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list