[Mono-bugs] [Bug 78155][Min] New - Assertion in Enum.ToObject (Type, object)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Apr 21 06:52:19 EDT 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 gert.driesen at pandora.be.

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

--- shadow/78155	2006-04-21 06:52:19.000000000 -0400
+++ shadow/78155.tmp.7392	2006-04-21 06:52:19.000000000 -0400
@@ -0,0 +1,64 @@
+Bug#: 78155
+Product: Mono: Runtime
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: gert.driesen at pandora.be               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Assertion in Enum.ToObject (Type, object)
+
+Calling Enum.ToObject(Type, object) results in an ArgumentException 
+containing an assertion message when the value is not an underlying type 
+for an enum (such as byte, int, ...).
+
+To reproduce this issue, compile and run the following code snippet:
+
+using System;
+
+public class Test {
+  static void Main () {
+    try {
+      object x = Enum.ToObject (typeof (Modifiers), "Public");
+    } catch (ArgumentException ex) {
+      Console.WriteLine (ex.Message);
+    }
+
+    try {
+      object x = Enum.ToObject (typeof (Modifiers), DateTime.Now);
+    } catch (ArgumentException ex) {
+      Console.WriteLine (ex.Message);
+    }
+  }
+
+  public enum Modifiers {
+    Public = 1,
+    Private = 2
+  }
+}
+
+Actual result:
+
+assertion `(objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 && 
+objc->byval_arg.type <= MONO_TYPE_U8)' failed
+Parameter name: obj
+assertion `(objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 && 
+objc->byval_arg.type <= MONO_TYPE_U8)' failed
+Parameter name: obj
+
+Expected result:
+
+The value passed in must be an enum base or an underlying type for an 
+enum, such as an Int32.
+Parameter name: value
+The value passed in must be an enum base or an underlying type for an 
+enum, such as an Int32.
+Parameter name: value


More information about the mono-bugs mailing list