2 // System.Reflection.Emit.GenericTypeParameterBuilder
4 // Martin Baulig (martin@ximian.com)
6 // (C) 2004 Novell, Inc.
10 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Reflection;
33 using System.Reflection.Emit;
34 using System.Collections;
35 using System.Runtime.CompilerServices;
36 using System.Globalization;
37 using System.Runtime.Serialization;
39 #if NET_2_0 || BOOTSTRAP_NET_2_0
40 namespace System.Reflection.Emit
42 public sealed class GenericTypeParameterBuilder : Type
44 #region Sync with reflection.h
45 private TypeBuilder tbuilder;
46 private MethodBuilder mbuilder;
49 private Type base_type;
50 private Type[] iface_constraints;
51 private bool has_ctor_constraint;
52 private bool has_reference_type;
53 private bool has_value_type;
56 public void SetBaseTypeConstraint (Type base_type_constraint)
58 this.base_type = base_type_constraint;
61 public void SetInterfaceConstraints (Type[] iface_constraints)
63 this.iface_constraints = iface_constraints;
66 public void Mono_SetConstructorConstraint ()
68 has_ctor_constraint = true;
71 public void Mono_SetReferenceTypeConstraint ()
73 has_reference_type = true;
76 public void Mono_SetValueTypeConstraint ()
78 has_value_type = true;
81 internal GenericTypeParameterBuilder (TypeBuilder tbuilder,
82 MethodBuilder mbuilder,
83 string name, int index)
85 this.tbuilder = tbuilder;
86 this.mbuilder = mbuilder;
93 [MethodImplAttribute(MethodImplOptions.InternalCall)]
94 private extern void initialize ();
96 public override bool IsSubclassOf (Type c)
101 return BaseType == c || BaseType.IsSubclassOf (c);
104 protected override TypeAttributes GetAttributeFlagsImpl ()
106 return TypeAttributes.Public;
109 protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
111 CallingConventions callConvention,
113 ParameterModifier[] modifiers)
115 throw not_supported ();
118 public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
120 throw not_supported ();
123 public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
125 throw not_supported ();
128 public override EventInfo[] GetEvents (BindingFlags bindingAttr)
130 throw not_supported ();
133 public override FieldInfo GetField (string name, BindingFlags bindingAttr)
135 throw not_supported ();
138 public override FieldInfo[] GetFields (BindingFlags bindingAttr)
140 throw not_supported ();
143 public override Type GetInterface (string name, bool ignoreCase)
145 throw not_supported ();
148 public override Type[] GetInterfaces ()
150 throw not_supported ();
153 public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
155 throw not_supported ();
158 public override MethodInfo [] GetMethods (BindingFlags bindingAttr)
160 throw not_supported ();
163 protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr,
165 CallingConventions callConvention,
166 Type[] types, ParameterModifier[] modifiers)
168 throw not_supported ();
171 public override Type GetNestedType (string name, BindingFlags bindingAttr)
173 throw not_supported ();
176 public override Type[] GetNestedTypes (BindingFlags bindingAttr)
178 throw not_supported ();
181 public override PropertyInfo [] GetProperties (BindingFlags bindingAttr)
183 throw not_supported ();
186 protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr,
187 Binder binder, Type returnType,
189 ParameterModifier[] modifiers)
191 throw not_supported ();
194 protected override bool HasElementTypeImpl ()
199 protected override bool IsArrayImpl ()
204 protected override bool IsByRefImpl ()
209 protected override bool IsCOMObjectImpl ()
214 protected override bool IsPointerImpl ()
219 protected override bool IsPrimitiveImpl ()
224 protected override bool IsValueTypeImpl ()
228 // return base_type != null ? base_type.IsValueType : false;
231 public override object InvokeMember (string name, BindingFlags invokeAttr,
232 Binder binder, object target, object[] args,
233 ParameterModifier[] modifiers,
234 CultureInfo culture, string[] namedParameters)
236 throw not_supported ();
239 public override Type GetElementType ()
241 throw not_supported ();
244 public override Type UnderlyingSystemType {
250 public override Assembly Assembly {
251 get { return tbuilder.Assembly; }
254 public override string AssemblyQualifiedName {
258 public override Type BaseType {
259 get { return base_type; }
262 public override string FullName {
266 public override Guid GUID {
267 get { return Guid.Empty; }
270 public override bool IsDefined (Type attributeType, bool inherit)
272 throw not_supported ();
275 public override object[] GetCustomAttributes (bool inherit)
277 throw not_supported ();
280 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
282 throw not_supported ();
285 public override MemberTypes MemberType {
286 get { return MemberTypes.TypeInfo; }
289 public override string Name {
293 public override string Namespace {
297 public override Module Module {
298 get { return tbuilder.Module; }
301 public override Type DeclaringType {
302 get { return mbuilder != null ? null : tbuilder; }
305 public override Type ReflectedType {
307 return DeclaringType;
311 public override RuntimeTypeHandle TypeHandle {
312 get { throw not_supported (); }
315 public override int GetArrayRank ()
317 throw not_supported ();
320 public override Type[] GetGenericArguments ()
322 throw not_supported ();
325 public override Type GetGenericTypeDefinition ()
327 throw not_supported ();
330 public override bool HasGenericArguments {
331 get { return false; }
334 public override bool ContainsGenericParameters {
335 get { return false; }
338 public override bool IsGenericParameter {
342 public override int GenericParameterPosition {
343 get { return index; }
346 public override MethodInfo DeclaringMethod {
347 get { return mbuilder; }
350 private Exception not_supported ()
352 return new NotSupportedException ();
355 public override string ToString ()