Browse Source

[System.Reflection.Emit] fix typo in ModuleBuilder.DefineType

Vlad Zaitsev 10 years ago
parent
commit
bd82bd3689

+ 1 - 1
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs

@@ -288,7 +288,7 @@ namespace System.Reflection.Emit {
 		}
 
 		public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, int typesize) {
-			return DefineType (name, attr, parent, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
+			return DefineType (name, attr, parent, null, PackingSize.Unspecified, typesize);
 		}
 
 		public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, PackingSize packsize) {

+ 11 - 0
mcs/class/corlib/Test/System.Reflection.Emit/ModuleBuilderTest.cs

@@ -240,6 +240,17 @@ namespace MonoTests.System.Reflection.Emit
 			Assert.AreEqual (typeof (ICollection), tb.BaseType, "#2");
 		}
 
+		[Test]
+		public void DefineType_TypeSize ()
+		{
+			AssemblyBuilder ab = genAssembly ();
+			ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+
+			TypeBuilder tb = mb.DefineType ("Foo", TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.SequentialLayout,
+				typeof (ValueType), 1);
+			Assert.AreEqual (1, tb.Size);
+		}
+
 		[Test]
 		[ExpectedException (typeof (ArgumentException))]
 		public void DuplicateTypeName () {