Browse Source

2009-07-15 Rodrigo Kumpera <[email protected]>

	* EnumBuilder.cs: Use new derived types for array, pointer and byref.

2009-07-15 Rodrigo Kumpera  <[email protected]>

	* DerivedTypesTest.cs: New tests for interaction with
	EnumBuilder objects.

svn path=/trunk/mcs/; revision=137989
Rodrigo Kumpera 16 years ago
parent
commit
6fa184bfef

+ 4 - 0
mcs/class/corlib/System.Reflection.Emit/ChangeLog

@@ -1,3 +1,7 @@
+2009-07-15 Rodrigo Kumpera  <[email protected]>
+
+	* EnumBuilder.cs: Use new derived types for array, pointer and byref.
+
 2009-07-15 Rodrigo Kumpera  <[email protected]>
 
 	* GenericTypeParameterBuilder.cs (MakeByRefType): Return an instance

+ 6 - 8
mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs

@@ -352,28 +352,26 @@ namespace System.Reflection.Emit {
 		}
 
 #if NET_2_0
-		[MonoTODO]
 		public override Type MakeArrayType ()
 		{
-			return base.MakeArrayType ();
+			return MakeArrayType (1);  
 		}
 
-		[MonoTODO]
 		public override Type MakeArrayType (int rank)
 		{
-			return base.MakeArrayType (rank);
+			if (rank < 1)
+				throw new IndexOutOfRangeException ();
+			return new ArrayType (this, rank);
 		}
 
-		[MonoTODO]
 		public override Type MakeByRefType ()
 		{
-			return base.MakeByRefType ();
+			return new ByRefType (this);
 		}
 
-		[MonoTODO]
 		public override Type MakePointerType ()
 		{
-			return base.MakePointerType ();
+			return new PointerType (this);
 		}
 #endif
 

+ 6 - 1
mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog

@@ -1,6 +1,11 @@
 2009-07-15 Rodrigo Kumpera  <[email protected]>
 
-	* DerivedTypesTest.cs: New tests for PointerTypeinteraction
+	* DerivedTypesTest.cs: New tests for interaction with
+	EnumBuilder objects.
+
+2009-07-15 Rodrigo Kumpera  <[email protected]>
+
+	* DerivedTypesTest.cs: New tests for PointerType interaction
 	with GenericTypeParameterBuilder.
 
 2009-07-15 Rodrigo Kumpera  <[email protected]>

+ 55 - 0
mcs/class/corlib/Test/System.Reflection.Emit/DerivedTypesTest.cs

@@ -1669,6 +1669,61 @@ namespace MonoTests.System.Reflection.Emit
 
 			Assert.AreEqual (gparam, arr.GetElementType (), "#22");
 		}
+
+		[Test]
+		public void GenericTypeMembersOfEnum ()
+		{
+			var eb = module.DefineEnum ("dd.enum", TypeAttributes.Public, typeof (int));
+			Type arr = eb.MakeArrayType ();
+
+			try {
+				arr.GetGenericArguments ();
+				Assert.Fail ("#1");
+			} catch (NotSupportedException) {}
+
+			try {
+				arr.GetGenericParameterConstraints ();
+				Assert.Fail ("#2");
+			} catch (InvalidOperationException) {}
+
+			try {
+				arr.GetGenericTypeDefinition ();
+				Assert.Fail ("#3");
+			} catch (NotSupportedException) {}
+		
+			Assert.IsFalse (arr.ContainsGenericParameters, "#4");
+			try {
+				var x = arr.GenericParameterAttributes;
+				Assert.Fail ("#5");
+			} catch (NotSupportedException) {}
+
+			try {
+				var x = arr.GenericParameterPosition;
+				Assert.Fail ("#6");
+			} catch (InvalidOperationException) {}
+
+
+			Assert.IsFalse (arr.IsGenericParameter, "#8");
+			Assert.IsFalse (arr.IsGenericType, "#9");
+			Assert.IsFalse (arr.IsGenericTypeDefinition, "#10");
+
+			Assert.AreEqual (TypeAttributes.Public | TypeAttributes.Sealed, arr.Attributes, "#11");
+
+			Assert.IsTrue (arr.HasElementType, "#12");
+			Assert.IsTrue (arr.IsArray, "#13");
+
+			Assert.AreEqual (assembly, arr.Assembly, "#14");
+			Assert.AreEqual ("dd.enum[], MonoTests.System.Reflection.Emit.TypeBuilderTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", arr.AssemblyQualifiedName, "#15");
+			Assert.AreEqual (typeof (Array), arr.BaseType, "#16");
+			Assert.AreEqual ("dd.enum[]", arr.FullName, "#17");
+			Assert.AreEqual (module, arr.Module, "#18");
+			Assert.AreEqual ("dd", arr.Namespace, "#19");
+			Assert.AreEqual (arr, arr.UnderlyingSystemType, "#20");
+			Assert.AreEqual ("enum[]", arr.Name, "#21");
+
+			Assert.AreEqual (eb, arr.GetElementType (), "#22");
+		}
+
 	}
 #endif
 }