[Mono-bugs] [Bug 80260][Nor] Changed - [GMCS] Can't convert IList<T> to T array

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Feb 4 00:29:18 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dmitchell at logos.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80260

--- shadow/80260	2007-02-04 00:24:45.000000000 -0500
+++ shadow/80260.tmp.4755	2007-02-04 00:29:18.000000000 -0500
@@ -64,6 +64,31 @@
 Mono without any problem. 
 
 ------- Additional Comments From dmitchell at logos.com  2007-02-04 00:24 -------
 Created an attachment (id=18615)
 This patch will fix bug 80260
 
+
+------- Additional Comments From dmitchell at logos.com  2007-02-04 00:29 -------
+I've attached a patch that will fix the problem on the compiler end.
+
+In testing the patch, I discovered that the runtime does not always behave like the 
+Microsoft implementation. For example, the following program will compile under the 
+Microsoft implementation, but the conversion will throw an exception:
+
+using System.Collections.Generic;
+
+class CantCastGenericListToArray
+{
+	public static void Main(string[] args)
+	{
+		IList<object> list = new object[] { "foo", "bar" };
+		string[] array = (string[])list;
+		if (list.Count != array.Length)
+		{
+			throw new System.ApplicationException();
+		}
+	}
+}
+
+However, no exceptions will be thrown in Mono. Does this qualify as a separate bug, or 
+should this one be left open?


More information about the mono-bugs mailing list