[Mono-bugs] [Bug 71300][Min] New - TestGetConstructorNullElementType

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 14 Jan 2005 19:21:39 -0500 (EST)


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 miguel@ximian.com.

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

--- shadow/71300	2005-01-14 19:21:39.000000000 -0500
+++ shadow/71300.tmp.14419	2005-01-14 19:21:39.000000000 -0500
@@ -0,0 +1,73 @@
+Bug#: 71300
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: miguel@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: TestGetConstructorNullElementType
+
+This program should print OK:
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+class X {
+		private static string _assemblyName =
+"MonoTests.System.Reflection.Emit.EnumBuilder";
+		private static string _moduleName = "EmittedModule";
+		private static string _enumNamespace = "MyNameSpace";
+		private static string _enumName = "MyEnum";
+		private static Type _enumType = typeof(Int32);
+		private static string _fieldName = "MyField";
+		private static object _fieldValue = 1;
+		private static AssemblyName GetAssemblyName ()
+		{
+			AssemblyName assemblyName = new AssemblyName ();
+			assemblyName.Name = _assemblyName;
+			return assemblyName;
+		}
+		private static AssemblyBuilder GenerateAssembly ()
+		{
+			return AppDomain.CurrentDomain.DefineDynamicAssembly (GetAssemblyName
+(), AssemblyBuilderAccess.RunAndSave);
+		}
+		private static ModuleBuilder GenerateModule ()
+		{
+			AssemblyBuilder assemblyBuilder = GenerateAssembly ();
+			return assemblyBuilder.DefineDynamicModule (_moduleName);
+		}
+		private static ModuleBuilder GenerateModule (AssemblyBuilder assemblyBuilder)
+		{
+			return assemblyBuilder.DefineDynamicModule (_moduleName);
+		}
+		private static EnumBuilder GenerateEnum ()
+		{
+			ModuleBuilder modBuilder = GenerateModule ();
+			return modBuilder.DefineEnum (_enumNamespace + "." + _enumName,
+TypeAttributes.Public, _enumType);
+		}
+
+	static void Main ()
+	{
+		try {
+			EnumBuilder enumBuilder = GenerateEnum ();
+			enumBuilder.CreateType ();
+			ConstructorInfo ctor = enumBuilder.GetConstructor (
+				BindingFlags.Public, null, CallingConventions.Any,
+				new Type[] { null }, new ParameterModifier[0]);
+		} catch (ArgumentNullException){
+			Console.WriteLine ("OK");
+		}
+	}
+}