{
partial class RuntimeType
{
+ internal Object GenericCache;
+
internal virtual MonoCMethod GetDefaultConstructor ()
{
// TODO: Requires MonoType
public override StructLayoutAttribute StructLayoutAttribute {
get {
- return GetStructLayoutAttribute ();
+ return StructLayoutAttribute.GetCustomAttribute (this);
}
}
return constraints;
}
- public override Type MakeGenericType (params Type[] typeArguments)
+ internal static object CreateInstanceForAnotherGenericParameter (Type genericType, RuntimeType genericArgument)
{
- if (IsUserType)
- throw new NotSupportedException ();
- if (!IsGenericTypeDefinition)
- throw new InvalidOperationException ("not a generic type definition");
- 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");
-
- bool hasUserType = false;
-
- Type[] systemTypes = new Type[typeArguments.Length];
- for (int i = 0; i < typeArguments.Length; ++i) {
- Type t = typeArguments [i];
- if (t == null)
- throw new ArgumentNullException ("typeArguments");
-
- if (!(t is MonoType))
- hasUserType = true;
- systemTypes [i] = t;
- }
-
- if (hasUserType) {
-#if FULL_AOT_RUNTIME
- throw new NotSupportedException ("User types are not supported under full aot");
-#else
- return new MonoGenericClass (this, typeArguments);
-#endif
- }
-
- Type res = MakeGenericType (this, systemTypes);
- if (res == null)
- throw new TypeLoadException ();
- return res;
+ var gt = (RuntimeType) MakeGenericType (genericType, new Type [] { genericArgument });
+ var ctor = gt.GetDefaultConstructor ();
+ return ctor.InternalInvoke (null, null);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
}
}
- StructLayoutAttribute GetStructLayoutAttribute ()
- {
- LayoutKind kind;
-
- if (IsLayoutSequential)
- kind = LayoutKind.Sequential;
- else if (IsExplicitLayout)
- kind = LayoutKind.Explicit;
- else
- kind = LayoutKind.Auto;
-
- StructLayoutAttribute attr = new StructLayoutAttribute (kind);
-
- if (IsUnicodeClass)
- attr.CharSet = CharSet.Unicode;
- else if (IsAnsiClass)
- attr.CharSet = CharSet.Ansi;
- else
- attr.CharSet = CharSet.Auto;
-
- if (kind != LayoutKind.Auto) {
- int packing;
- GetPacking (out packing, out attr.Size);
- // 0 means no data provided, we end up with default value
- if (packing != 0)
- attr.Pack = packing;
- }
-
- return attr;
- }
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern void GetPacking (out int packing, out int size);
+ internal extern void GetPacking (out int packing, out int size);
#if MONO_COM
private static Dictionary<Guid, Type> clsid_types;
internal extern string getFullName(bool full_name, bool assembly_qualified);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern override Type [] GetGenericArguments ();
+ extern Type[] GetGenericArgumentsInternal (bool runtimeArray);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern GenericParameterAttributes GetGenericParameterAttributes ();