[Mono-bugs] [Bug 76136][Nor] New - [GMCS] Getting a generic struct via reflection fails

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Sep 17 09:13:57 EDT 2005


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 kiess at h3c.de.

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

--- shadow/76136	2005-09-17 09:13:57.000000000 -0400
+++ shadow/76136.tmp.4538	2005-09-17 09:13:57.000000000 -0400
@@ -0,0 +1,67 @@
+Bug#: 76136
+Product: Mono: Runtime
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: kiess at h3c.de               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [GMCS] Getting a generic struct via reflection fails
+
+Description of Problem:
+When reading a generic struct with System.Reflection.FieldInfo.GetValue the
+returned value is wrong.
+
+Steps to reproduce the problem:
+1. cat > test.cs << EOF
+public struct Container<T> {
+  public T content;
+  
+  public Container (T content) {
+    this.content = content;
+  }
+}
+
+public class A {
+  public Container<int> field;
+  
+  public A () {
+    field = new Container<int> (1);
+  }
+}
+
+public class M {
+  public static void Main() {
+    A a = new A();
+
+    System.Console.WriteLine (a.field.content);
+
+    object o = a.GetType().GetField("field").GetValue (a);
+    Container<int> unboxed = (Container<int>)o;
+    System.Console.WriteLine (unboxed.content);
+  }
+}
+EOF
+2. gmcs test.cs
+3. mono test.exe
+
+Actual Results:
+1
+0
+
+Expected Results:
+1
+1
+
+How often does this happen? 
+always
+
+Additional Information:


More information about the mono-bugs mailing list