[Mono-bugs] [Bug 77888][Wis] New - Generics bug: NullReference

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Mar 23 16:35:21 EST 2006


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 adam.lofts at gmail.com.

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

--- shadow/77888	2006-03-23 16:35:21.000000000 -0500
+++ shadow/77888.tmp.32597	2006-03-23 16:35:21.000000000 -0500
@@ -0,0 +1,98 @@
+Bug#: 77888
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: adam.lofts at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Generics bug: NullReference
+
+I'm pretty sure this is a mono bug (sorry if its not). Not sure if compiler
+or runtime.
+
+Not sure even if this is valid C#.
+
+adam at a3000:~/Desktop$ cat Test.cs
+using System;
+using System.Threading;
+using System.Collections.Generic;
+using System.Reflection;
+
+public class A
+{
+        public static void Go <T1, T2> (KeyValuePair <T1, T2> kvp)
+        {
+                Console.WriteLine ("Go: Kvp: {0}", kvp);
+                Console.WriteLine ("Go: 1: {0} 2: {1}", kvp.Key, kvp.Value);
+        }
+
+        public static void Main ()
+        {
+                KeyValuePair<string, uint> kvp = new KeyValuePair<string,
+uint> ("a", 21);
+                Type type = kvp.GetType ();
+                Type [] arguments = type.GetGenericArguments ();
+                MethodInfo method = typeof (A).GetMethod ("Go");
+                MethodInfo generic_method = method.MakeGenericMethod
+(arguments);
+                Console.WriteLine ("About to invoke: {0}", method);
+                generic_method.Invoke (null, new object [] { kvp });
+        }
+}
+adam at a3000:~/Desktop$ gmcs Test.cs -out:Test.exe
+adam at a3000:~/Desktop$ ./Test.exe
+About to invoke: Void Go[T1,T2](KeyValuePair`2)
+
+Unhandled Exception: System.Reflection.TargetInvocationException: Exception
+has been thrown by the target of an invocation. --->
+System.NullReferenceException: Object reference not set to an instance of
+an object
+in <0x0009a>
+System.Collections.Generic.KeyValuePair`2[System.String,System.UInt32]:ToString
+()
+in <0x00340> System.String:FormatHelper (System.Text.StringBuilder result,
+IFormatProvider provider, System.String format, System.Object[] args)
+in <0x0004d> System.String:Format (IFormatProvider provider, System.String
+format, System.Object[] args)
+in <0x00056> System.String:Format (System.String format, System.Object arg0)
+in <0x00027> System.IO.TextWriter:Write (System.String format,
+System.Object arg0)
+in <0x0002b> System.IO.TextWriter:WriteLine (System.String format,
+System.Object arg0)
+in <0x00040> System.IO.SynchronizedWriter:WriteLine (System.String format,
+System.Object value)
+in <0x00033> System.Console:WriteLine (System.String format, System.Object
+arg0)in <0x0003a> A:Go[String,UInt32] (KeyValuePair`2 kvp)
+in <0x00000> <unknown method>
+in (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
+(object,object[])
+in <0x000da> System.Reflection.MonoMethod:Invoke (System.Object obj,
+BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[]
+parameters, System.Globalization.CultureInfo culture)--- End of inner
+exception stack trace ---
+
+in <0x00179> System.Reflection.MonoMethod:Invoke (System.Object obj,
+BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[]
+parameters, System.Globalization.CultureInfo culture)
+in <0x00034> System.Reflection.MethodBase:Invoke (System.Object obj,
+System.Object[] parameters)
+in <0x00122> A:Main ()
+
+adam at a3000:~/Desktop$ mono --version
+Mono JIT compiler version 1.1.13.4, (C) 2002-2005 Novell, Inc and
+Contributors. www.mono-project.com
+        TLS:           __thread
+        GC:            Included Boehm (with typed GC)
+        SIGSEGV      : normal
+
+adam at a3000:~/Desktop$ gmcs --version
+Mono C# compiler version 1.1.13.4


More information about the mono-bugs mailing list