2 // System.Reflection.Emit.GenericTypeParameterBuilder
4 // Martin Baulig (martin@ximian.com)
6 // (C) 2004 Novell, Inc.
9 using System.Reflection;
10 using System.Reflection.Emit;
11 using System.Collections;
12 using System.Runtime.CompilerServices;
13 using System.Globalization;
14 using System.Runtime.Serialization;
16 #if BOOTSTRAP_NET_2_0//NET_2_0 | BOOTSTRAP_NET_2_0
17 namespace System.Reflection.Emit
19 public sealed class GenericTypeParameterBuilder : Type
21 #region Sync with reflection.h
22 private TypeBuilder tbuilder;
23 private MethodBuilder mbuilder;
26 private Type base_type;
27 private Type[] iface_constraints;
28 private bool has_ctor_constraint;
29 private bool has_reference_type;
30 private bool has_value_type;
33 public void SetBaseTypeConstraint (Type base_type_constraint)
35 this.base_type = base_type_constraint;
38 public void SetInterfaceConstraints (Type[] iface_constraints)
40 this.iface_constraints = iface_constraints;
43 public void Mono_SetConstructorConstraint ()
45 has_ctor_constraint = true;
48 public void Mono_SetReferenceTypeConstraint ()
50 has_reference_type = true;
53 public void Mono_SetValueTypeConstraint ()
55 has_value_type = true;
58 internal GenericTypeParameterBuilder (TypeBuilder tbuilder,
59 MethodBuilder mbuilder,
60 string name, int index)
62 this.tbuilder = tbuilder;
63 this.mbuilder = mbuilder;
70 [MethodImplAttribute(MethodImplOptions.InternalCall)]
71 private extern void initialize ();
73 public override bool IsSubclassOf (Type c)
78 return BaseType == c || BaseType.IsSubclassOf (c);
81 protected override TypeAttributes GetAttributeFlagsImpl ()
83 return TypeAttributes.Public;
86 protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
88 CallingConventions callConvention,
90 ParameterModifier[] modifiers)
92 throw not_supported ();
95 public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
97 throw not_supported ();
100 public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
102 throw not_supported ();
105 public override EventInfo[] GetEvents (BindingFlags bindingAttr)
107 throw not_supported ();
110 public override FieldInfo GetField (string name, BindingFlags bindingAttr)
112 throw not_supported ();
115 public override FieldInfo[] GetFields (BindingFlags bindingAttr)
117 throw not_supported ();
120 public override Type GetInterface (string name, bool ignoreCase)
122 throw not_supported ();
125 public override Type[] GetInterfaces ()
127 throw not_supported ();
130 public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
132 throw not_supported ();
135 public override MethodInfo [] GetMethods (BindingFlags bindingAttr)
137 throw not_supported ();
140 protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr,
142 CallingConventions callConvention,
143 Type[] types, ParameterModifier[] modifiers)
145 throw not_supported ();
148 public override Type GetNestedType (string name, BindingFlags bindingAttr)
150 throw not_supported ();
153 public override Type[] GetNestedTypes (BindingFlags bindingAttr)
155 throw not_supported ();
158 public override PropertyInfo [] GetProperties (BindingFlags bindingAttr)
160 throw not_supported ();
163 protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr,
164 Binder binder, Type returnType,
166 ParameterModifier[] modifiers)
168 throw not_supported ();
171 protected override bool HasElementTypeImpl ()
176 protected override bool IsArrayImpl ()
181 protected override bool IsByRefImpl ()
186 protected override bool IsCOMObjectImpl ()
191 protected override bool IsPointerImpl ()
196 protected override bool IsPrimitiveImpl ()
201 protected override bool IsValueTypeImpl ()
205 // return base_type != null ? base_type.IsValueType : false;
208 public override object InvokeMember (string name, BindingFlags invokeAttr,
209 Binder binder, object target, object[] args,
210 ParameterModifier[] modifiers,
211 CultureInfo culture, string[] namedParameters)
213 throw not_supported ();
216 public override Type GetElementType ()
218 throw not_supported ();
221 public override Type UnderlyingSystemType {
227 public override Assembly Assembly {
228 get { return tbuilder.Assembly; }
231 public override string AssemblyQualifiedName {
235 public override Type BaseType {
236 get { return base_type; }
239 public override string FullName {
243 public override Guid GUID {
244 get { return Guid.Empty; }
247 public override bool IsDefined (Type attributeType, bool inherit)
249 throw not_supported ();
252 public override object[] GetCustomAttributes (bool inherit)
254 throw not_supported ();
257 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
259 throw not_supported ();
262 public override MemberTypes MemberType {
263 get { return MemberTypes.TypeInfo; }
266 public override string Name {
270 public override string Namespace {
274 public override Module Module {
275 get { return tbuilder.Module; }
278 public override Type DeclaringType {
279 get { return mbuilder != null ? null : tbuilder; }
282 public override Type ReflectedType {
284 return DeclaringType;
288 public override RuntimeTypeHandle TypeHandle {
289 get { throw not_supported (); }
292 public override int GetArrayRank ()
294 throw not_supported ();
297 public override Type[] GetGenericArguments ()
299 throw not_supported ();
302 public override Type GetGenericTypeDefinition ()
304 throw not_supported ();
307 public override bool HasGenericArguments {
308 get { return false; }
311 public override bool ContainsGenericParameters {
312 get { return false; }
315 public override bool IsGenericParameter {
319 public override int GenericParameterPosition {
320 get { return index; }
323 public override MethodInfo DeclaringMethod {
324 get { return mbuilder; }
327 private Exception not_supported ()
329 return new NotSupportedException ();
332 public override string ToString ()