static bool FilterName_impl (MemberInfo m, object filterCriteria)
{
string name = (string) filterCriteria;
- if (name == null || name.Length == 0 )
+ if (name == null || name.Length == 0 )
return false; // because m.Name cannot be null or empty
if (name [name.Length-1] == '*')
static bool FilterNameIgnoreCase_impl (MemberInfo m, object filterCriteria)
{
string name = (string) filterCriteria;
- if (name == null || name.Length == 0 )
+ if (name == null || name.Length == 0 )
return false; // because m.Name cannot be null or empty
if (name [name.Length-1] == '*')
}
}
+ /*
+ * This has NOTHING to do with getting the base type of an enum. Use
+ * Enum.GetUnderlyingType () for that.
+ */
public abstract Type UnderlyingSystemType {get;}
public override bool Equals (object o)
return Equals (cmp);
}
- public bool Equals (Type type) {
- if (type == null)
+ public bool Equals (Type o) {
+ if (o == null)
return false;
- return UnderlyingSystemType.EqualsInternal (type.UnderlyingSystemType);
+ return UnderlyingSystemType.EqualsInternal (o.UnderlyingSystemType);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static Type GetType(string typeName)
{
if (typeName == null)
- throw new ArgumentNullException ("typeName");
+#if NET_2_0
+ throw new ArgumentNullException ("TypeName");
+#else
+ throw new ArgumentNullException ("className");
+#endif
return internal_from_name (typeName, false, false);
}
public static Type GetType(string typeName, bool throwOnError)
{
if (typeName == null)
- throw new ArgumentNullException ("typeName");
+#if NET_2_0
+ throw new ArgumentNullException ("TypeName");
+#else
+ throw new ArgumentNullException ("className");
+#endif
Type type = internal_from_name (typeName, throwOnError, false);
if (throwOnError && type == null)
public static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
{
if (typeName == null)
- throw new ArgumentNullException ("typeName");
+#if NET_2_0
+ throw new ArgumentNullException ("TypeName");
+#else
+ throw new ArgumentNullException ("className");
+#endif
Type t = internal_from_name (typeName, throwOnError, ignoreCase);
if (throwOnError && t == null)
internal extern static TypeCode GetTypeCodeInternal (Type type);
public static TypeCode GetTypeCode (Type type) {
+ if (type is MonoType)
+ return GetTypeCodeInternal (type);
if (type == null)
/* MS.NET returns this */
return TypeCode.Empty;
type = type.UnderlyingSystemType;
if (!type.IsSystemType)
- return Type.GetTypeCode (typeof (object));
+ return TypeCode.Object;
else
return GetTypeCodeInternal (type);
}
}
public static Type GetTypeFromHandle (RuntimeTypeHandle handle)
- {
+ {
+ if (handle.Value == IntPtr.Zero)
+#if NET_2_0
+ // This is not consistent with the other GetXXXFromHandle methods, but
+ // MS.NET seems to do this
+ return null;
+#else
+ throw new ArgumentException ("The handle is invalid.");
+#endif
+
return internal_from_handle (handle.Value);
}
public static RuntimeTypeHandle GetTypeHandle (object o)
{
+ if (o == null)
+#if NET_2_0
+ throw new ArgumentNullException ();
+#else
+ throw new ArgumentNullException ("o");
+#endif
+
return o.GetType().TypeHandle;
}
public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder,
Type[] types, ParameterModifier[] modifiers)
{
-
return GetMethod (name, bindingAttr, binder, CallingConventions.Any, types, modifiers);
}
#endif
public ConstructorInfo GetConstructor (Type[] types)
{
- return GetConstructor (DefaultBindingFlags, null, CallingConventions.Any, types, null);
+ return GetConstructor (BindingFlags.Public|BindingFlags.Instance, null, CallingConventions.Any, types, null);
}
#if NET_2_0
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern Type MakeGenericType (Type gt, Type [] types);
- public virtual Type MakeGenericType (params Type[] types)
+ public virtual Type MakeGenericType (params Type[] typeArguments)
{
if (!IsGenericTypeDefinition)
throw new InvalidOperationException ("not a generic type definition");
- if (types == null)
- throw new ArgumentNullException ("types");
-
- Type[] systemTypes = new Type[types.Length];
- for (int i = 0; i < types.Length; ++i) {
- Type t = types [i];
+ if (typeArguments == null)
+ throw new ArgumentNullException ("typeArguments");
+ if (GetGenericArguments().Length != typeArguments.Length)
+ throw new ArgumentException (String.Format ("The type or method has {0} generic parameter(s) but {1} generic argument(s) where provided. A generic argument must be provided for each generic parameter.", GetGenericArguments ().Length, typeArguments.Length), "typeArguments");
+
+ Type[] systemTypes = new Type[typeArguments.Length];
+ for (int i = 0; i < typeArguments.Length; ++i) {
+ Type t = typeArguments [i];
if (t == null)
- throw new ArgumentNullException ("types");
+ throw new ArgumentNullException ("typeArguments");
t = t.UnderlyingSystemType;
if (t == null || !t.IsSystemType)
- throw new ArgumentNullException ("types");
- systemTypes [i] = types [i].UnderlyingSystemType;
+ throw new ArgumentNullException ("typeArguments");
+ systemTypes [i] = typeArguments [i].UnderlyingSystemType;
}
-
+
Type res = MakeGenericType (this, systemTypes);
if (res == null)
throw new TypeLoadException ();
Assembly a;
try {
a = Assembly.ReflectionOnlyLoad (an);
- } catch (Exception ex) {
+ } catch {
if (throwIfNotFound)
throw;
return null;