[Mono-bugs] [Bug 62284][Wis] New - AssemblyBuilder.GetTypes() raises System.OutOfMemoryException

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 2 Aug 2004 12:29:37 -0400 (EDT)


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 rbo@acm.org.

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

--- shadow/62284	2004-08-02 12:29:37.000000000 -0400
+++ shadow/62284.tmp.26650	2004-08-02 12:29:37.000000000 -0400
@@ -0,0 +1,59 @@
+Bug#: 62284
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: rbo@acm.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: AssemblyBuilder.GetTypes() raises System.OutOfMemoryException
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+using NUnit.Framework;
+
+namespace MonoTestFixtures
+{
+	[TestFixture]
+	public class GetTypesTestFixture
+	{	
+		[Test]
+		public void GetTypes()
+		{
+			AssemblyName name = new AssemblyName();
+			name.Name = "GetTypesAssembly";
+		
+			AssemblyBuilder assemblyBuilder =
+AppDomain.CurrentDomain.DefineDynamicAssembly(name,AssemblyBuilderAccess.Run);
+			
+			ModuleBuilder moduleBuilder =
+assemblyBuilder.DefineDynamicModule("GetTypesModule");
+			
+			TypeBuilder fooBuilder = moduleBuilder.DefineType("Foo",
+TypeAttributes.Class);
+			TypeBuilder barBuilder = moduleBuilder.DefineType("Bar",
+TypeAttributes.Class);
+
+			Type foo = fooBuilder.CreateType();
+			Type bar = barBuilder.CreateType();
+			
+			Assert.IsNotNull(foo);
+			Assert.IsNotNull(bar);
+			
+			Type[] types = assemblyBuilder.GetTypes();
+			Assert.AreEqual(2, types.Length);
+			Assert.AreEqual(true, ((IList)types).Contains(foo));
+			Assert.AreEqual(true, ((IList)types).Contains(bar));
+		}
+	}
+}