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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +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#. + [EMAIL PROTECTED]:~/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 }); + } +} [EMAIL PROTECTED]:~/Desktop$ gmcs Test.cs -out:Test.exe [EMAIL PROTECTED]:~/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 () + [EMAIL PROTECTED]:~/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 + [EMAIL PROTECTED]:~/Desktop$ gmcs --version +Mono C# compiler version 1.1.13.4 _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
