+2010-03-11 Rodrigo Kumpera <rkumpera@novell.com>
+
+ * TypeBuilder.cs (GetMethod): Allow type to be the typebuilder itself.
+ Add better error checking to GetConstructor and GetField.
+
+ Fixes #587106.
+
2010-02-09 Sebastien Pouliot <sebastien@ximian.com>
* ModuleBuilder.cs: Do not use reflection to create SymbolWriterImpl
if (type == null)
throw new ArgumentException ("Type is not generic", "type");
+ if (!type.IsGenericType)
+ throw new ArgumentException ("Type is not a generic type", "type");
+
+ if (type.IsGenericTypeDefinition)
+ throw new ArgumentException ("Type cannot be a generic type definition", "type");
+
if (constructor == null)
throw new NullReferenceException (); //MS raises this instead of an ArgumentNullException
if (!IsValidGetMethodType (type))
throw new ArgumentException ("type is not TypeBuilder but " + type.GetType (), "type");
+ if (type is TypeBuilder && type.ContainsGenericParameters)
+ type = type.MakeGenericType (type.GetGenericArguments ());
+
if (!type.IsGenericType)
throw new ArgumentException ("type is not a generic type", "type");
public static FieldInfo GetField (Type type, FieldInfo field)
{
+ if (!type.IsGenericType)
+ throw new ArgumentException ("Type is not a generic type", "type");
+
+ if (type.IsGenericTypeDefinition)
+ throw new ArgumentException ("Type cannot be a generic type definition", "type");
+
FieldInfo res = type.GetField (field);
if (res == null)
throw new System.Exception ("field not found");