// Authors:
// Nick Drochak II (ndrochak@gol.com)
// Gonzalo Paniagua (gonzalo@ximian.com)
+// Marek Safar (marek.safar@gmail.com)
//
// (C) 2001 Nick Drochak II
// (c) 2002 Ximian, Inc. (http://www.ximian.com)
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
type.FullName + "."));
}
- return ctor.Invoke (null);
+ return ctor.InternalInvoke (null, null);
}
private static void CheckType (Type type)
// Paolo Molaro (lupus@ximian.com)
// Patrik Torstensson (patrik.torstensson@labs2.com)
// Gonzalo Paniagua (gonzalo@ximian.com)
+// Marek Safar (marek.safar@gmail.com)
//
// (c) 2001-2003 Ximian, Inc.
// Copyright (C) 2003-2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
[StructLayout (LayoutKind.Sequential)]
internal class MonoTypeInfo {
public string full_name;
- public ConstructorInfo default_ctor;
+ public MonoCMethod default_ctor;
}
[Serializable]
[StructLayout (LayoutKind.Sequential)]
- internal class MonoType : Type, ISerializable
+ sealed class MonoType : Type, ISerializable
{
[NonSerialized]
MonoTypeInfo type_info;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern TypeAttributes get_attributes (Type type);
- internal ConstructorInfo GetDefaultConstructor () {
- ConstructorInfo ctor = null;
+ public MonoCMethod GetDefaultConstructor ()
+ {
+ MonoCMethod ctor = null;
if (type_info == null)
type_info = new MonoTypeInfo ();
- if ((ctor = type_info.default_ctor) == null) {
- const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;
-
- ctor = type_info.default_ctor = GetConstructor (flags, null, CallingConventions.Any, Type.EmptyTypes, null);
+ else
+ ctor = type_info.default_ctor;
+
+ if (ctor == null) {
+ var ctors = GetConstructors (BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
+
+ for (int i = 0; i < ctors.Length; ++i) {
+ if (ctors [0].GetParametersCount () == 0) {
+ type_info.default_ctor = ctor = (MonoCMethod) ctors [i];
+ break;
+ }
+ }
}
return ctor;