Export (0) Print
Expand All

GenericTypeParameterBuilder Class

Defines and creates generic type parameters for dynamically defined generic types and methods. This class cannot be inherited.

System.Object
  System.Reflection.MemberInfo
    System.Type
      System.Reflection.Emit.GenericTypeParameterBuilder

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

[<Sealed>]
[<ComVisibleAttribute(true)>]
type GenericTypeParameterBuilder =  
    class
        inherit Type
    end

The GenericTypeParameterBuilder type exposes the following members.

  NameDescription
Public propertyAssemblyGets an Assembly object representing the dynamic assembly that contains the generic type definition the current type parameter belongs to. (Overrides Type.Assembly.)
Public propertyAssemblyQualifiedNameGets a null reference (Nothing in Visual Basic) in all cases. (Overrides Type.AssemblyQualifiedName.)
Public propertyAttributesGets the attributes associated with the Type. (Inherited from Type.)
Public propertyBaseTypeGets the base type constraint of the current generic type parameter. (Overrides Type.BaseType.)
Public propertyContainsGenericParametersGets true in all cases. (Overrides Type.ContainsGenericParameters.)
Public propertyDeclaringMethodGets a MethodInfo that represents the declaring method, if the current GenericTypeParameterBuilder represents a type parameter of a generic method. (Overrides Type.DeclaringMethod.)
Public propertyDeclaringTypeGets the generic type definition or generic method definition to which the generic type parameter belongs. (Overrides Type.DeclaringType.)
Public propertyFullNameGets a null reference (Nothing in Visual Basic) in all cases. (Overrides Type.FullName.)
Public propertyGenericParameterAttributesGets a combination of GenericParameterAttributes flags that describe the covariance and special constraints of the current generic type parameter. (Inherited from Type.)
Public propertyGenericParameterPositionGets the position of the type parameter in the type parameter list of the generic type or method that declared the parameter. (Overrides Type.GenericParameterPosition.)
Public propertyGUIDNot supported for incomplete generic type parameters. (Overrides Type.GUID.)
Public propertyHasElementTypeGets a value indicating whether the current Type encompasses or refers to another type; that is, whether the current Type is an array, a pointer, or is passed by reference. (Inherited from Type.)
Public propertyIsAbstractGets a value indicating whether the Type is abstract and must be overridden. (Inherited from Type.)
Public propertyIsAnsiClassGets a value indicating whether the string format attribute AnsiClass is selected for the Type. (Inherited from Type.)
Public propertyIsArrayGets a value indicating whether the Type is an array. (Inherited from Type.)
Public propertyIsAutoClassGets a value indicating whether the string format attribute AutoClass is selected for the Type. (Inherited from Type.)
Public propertyIsAutoLayoutGets a value indicating whether the class layout attribute AutoLayout is selected for the Type. (Inherited from Type.)
Public propertyIsByRefGets a value indicating whether the Type is passed by reference. (Inherited from Type.)
Public propertyIsClassGets a value indicating whether the Type is a class; that is, not a value type or interface. (Inherited from Type.)
Public propertyIsCOMObjectGets a value indicating whether the Type is a COM object. (Inherited from Type.)
Public propertyIsContextfulGets a value indicating whether the Type can be hosted in a context. (Inherited from Type.)
Public propertyIsEnumGets a value indicating whether the current Type represents an enumeration. (Inherited from Type.)
Public propertyIsExplicitLayoutGets a value indicating whether the class layout attribute ExplicitLayout is selected for the Type. (Inherited from Type.)
Public propertyIsGenericParameterGets true in all cases. (Overrides Type.IsGenericParameter.)
Public propertyIsGenericTypeReturns false in all cases. (Overrides Type.IsGenericType.)
Public propertyIsGenericTypeDefinitionGets false in all cases. (Overrides Type.IsGenericTypeDefinition.)
Public propertyIsImportGets a value indicating whether the Type has a ComImportAttribute attribute applied, indicating that it was imported from a COM type library. (Inherited from Type.)
Public propertyIsInterfaceGets a value indicating whether the Type is an interface; that is, not a class or a value type. (Inherited from Type.)
Public propertyIsLayoutSequentialGets a value indicating whether the class layout attribute SequentialLayout is selected for the Type. (Inherited from Type.)
Public propertyIsMarshalByRefGets a value indicating whether the Type is marshaled by reference. (Inherited from Type.)
Public propertyIsNestedGets a value indicating whether the current Type object represents a type whose definition is nested inside the definition of another type. (Inherited from Type.)
Public propertyIsNestedAssemblyGets a value indicating whether the Type is nested and visible only within its own assembly. (Inherited from Type.)
Public propertyIsNestedFamANDAssemGets a value indicating whether the Type is nested and visible only to classes that belong to both its own family and its own assembly. (Inherited from Type.)
Public propertyIsNestedFamilyGets a value indicating whether the Type is nested and visible only within its own family. (Inherited from Type.)
Public propertyIsNestedFamORAssemGets a value indicating whether the Type is nested and visible only to classes that belong to either its own family or to its own assembly. (Inherited from Type.)
Public propertyIsNestedPrivateGets a value indicating whether the Type is nested and declared private. (Inherited from Type.)
Public propertyIsNestedPublicGets a value indicating whether a class is nested and declared public. (Inherited from Type.)
Public propertyIsNotPublicGets a value indicating whether the Type is not declared public. (Inherited from Type.)
Public propertyIsPointerGets a value indicating whether the Type is a pointer. (Inherited from Type.)
Public propertyIsPrimitiveGets a value indicating whether the Type is one of the primitive types. (Inherited from Type.)
Public propertyIsPublicGets a value indicating whether the Type is declared public. (Inherited from Type.)
Public propertyIsSealedGets a value indicating whether the Type is declared sealed. (Inherited from Type.)
Public propertyIsSecurityCriticalGets a value that indicates whether the current type is security-critical or security-safe-critical at the current trust level, and therefore can perform critical operations. (Inherited from Type.)
Public propertyIsSecuritySafeCriticalGets a value that indicates whether the current type is security-safe-critical at the current trust level; that is, whether it can perform critical operations and can be accessed by transparent code. (Inherited from Type.)
Public propertyIsSecurityTransparentGets a value that indicates whether the current type is transparent at the current trust level, and therefore cannot perform critical operations. (Inherited from Type.)
Public propertyIsSerializableGets a value indicating whether the Type is serializable. (Inherited from Type.)
Public propertyIsSpecialNameGets a value indicating whether the Type has a name that requires special handling. (Inherited from Type.)
Public propertyIsUnicodeClassGets a value indicating whether the string format attribute UnicodeClass is selected for the Type. (Inherited from Type.)
Public propertyIsValueTypeGets a value indicating whether the Type is a value type. (Inherited from Type.)
Public propertyIsVisibleGets a value indicating whether the Type can be accessed by code outside the assembly. (Inherited from Type.)
Public propertyMemberTypeGets a MemberTypes value indicating that this member is a type or a nested type. (Inherited from Type.)
Public propertyMetadataTokenGets a value that identifies a metadata element. (Inherited from MemberInfo.)
Public propertyModuleGets the dynamic module that contains the generic type parameter. (Overrides Type.Module.)
Public propertyNameGets the name of the generic type parameter. (Overrides MemberInfo.Name.)
Public propertyNamespaceGets a null reference (Nothing in Visual Basic) in all cases. (Overrides Type.Namespace.)
Public propertyReflectedTypeGets the Type object that was used to obtain the GenericTypeParameterBuilder. (Overrides Type.ReflectedType.)
Public propertyStructLayoutAttributeGets a StructLayoutAttribute that describes the layout of the current type. (Inherited from Type.)
Public propertyTypeHandleNot supported for incomplete generic type parameters. (Overrides Type.TypeHandle.)
Public propertyTypeInitializerGets the initializer for the Type. (Inherited from Type.)
Public propertyUnderlyingSystemTypeGets the current generic type parameter. (Overrides Type.UnderlyingSystemType.)
Top

  NameDescription
Public methodEquals(Object)Tests whether the given object is an instance of EventToken and is equal to the current instance. (Overrides Type.Equals(Object).)
Public methodEquals(Type)Determines if the underlying system type of the current Type is the same as the underlying system type of the specified Type. (Inherited from Type.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindInterfacesReturns an array of Type objects representing a filtered list of interfaces implemented or inherited by the current Type. (Inherited from Type.)
Public methodFindMembersReturns a filtered array of MemberInfo objects of the specified member type. (Inherited from Type.)
Public methodGetArrayRankGets the number of dimensions in an Array. (Inherited from Type.)
Protected methodGetAttributeFlagsImplWhen overridden in a derived class, implements the Attributes property and gets a bitmask indicating the attributes associated with the Type. (Inherited from Type.)
Public methodGetConstructor(Type[])Searches for a public instance constructor whose parameters match the types in the specified array. (Inherited from Type.)
Public methodGetConstructor(BindingFlags, Binder, Type[], ParameterModifier[])Searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.)
Public methodGetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])Searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention. (Inherited from Type.)
Protected methodGetConstructorImplWhen overridden in a derived class, searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention. (Inherited from Type.)
Public methodGetConstructors()Returns all the public constructors defined for the current Type. (Inherited from Type.)
Public methodGetConstructors(BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetConstructors(BindingFlags).)
Public methodGetCustomAttributes(Boolean)Not supported for incomplete generic type parameters. (Overrides MemberInfo.GetCustomAttributes(Boolean).)
Public methodGetCustomAttributes(Type, Boolean)Not supported for incomplete generic type parameters. (Overrides MemberInfo.GetCustomAttributes(Type, Boolean).)
Public methodGetCustomAttributesDataReturns a list of CustomAttributeData objects representing data about the attributes that have been applied to the target member. (Inherited from MemberInfo.)
Public methodGetDefaultMembersSearches for the members defined for the current Type whose DefaultMemberAttribute is set. (Inherited from Type.)
Public methodGetElementTypeThrows a NotSupportedException in all cases. (Overrides Type.GetElementType().)
Public methodGetEnumNameReturns the name of the constant that has the specified value, for the current enumeration type. (Inherited from Type.)
Public methodGetEnumNamesReturns the names of the members of the current enumeration type. (Inherited from Type.)
Public methodGetEnumUnderlyingTypeReturns the underlying type of the current enumeration type. (Inherited from Type.)
Public methodGetEnumValuesReturns an array of the values of the constants in the current enumeration type. (Inherited from Type.)
Public methodGetEvent(String)Returns the EventInfo object representing the specified public event. (Inherited from Type.)
Public methodGetEvent(String, BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetEvent(String, BindingFlags).)
Public methodGetEvents()Not supported for incomplete generic type parameters. (Overrides Type.GetEvents().)
Public methodGetEvents(BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetEvents(BindingFlags).)
Public methodGetField(String)Searches for the public field with the specified name. (Inherited from Type.)
Public methodGetField(String, BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetField(String, BindingFlags).)
Public methodGetFields()Returns all the public fields of the current Type. (Inherited from Type.)
Public methodGetFields(BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetFields(BindingFlags).)
Public methodGetGenericArgumentsNot valid for generic type parameters. (Overrides Type.GetGenericArguments().)
Public methodGetGenericParameterConstraintsReturns an array of Type objects that represent the constraints on the current generic type parameter. (Inherited from Type.)
Public methodGetGenericTypeDefinitionNot valid for generic type parameters. (Overrides Type.GetGenericTypeDefinition().)
Public methodGetHashCodeReturns a 32-bit integer hash code for the current instance. (Overrides Type.GetHashCode().)
Public methodGetInterface(String)Searches for the interface with the specified name. (Inherited from Type.)
Public methodGetInterface(String, Boolean)Not supported for incomplete generic type parameters. (Overrides Type.GetInterface(String, Boolean).)
Public methodGetInterfaceMapNot supported for incomplete generic type parameters. (Overrides Type.GetInterfaceMap(Type).)
Public methodGetInterfacesNot supported for incomplete generic type parameters. (Overrides Type.GetInterfaces().)
Public methodGetMember(String)Searches for the public members with the specified name. (Inherited from Type.)
Public methodGetMember(String, BindingFlags)Searches for the specified members, using the specified binding constraints. (Inherited from Type.)
Public methodGetMember(String, MemberTypes, BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetMember(String, MemberTypes, BindingFlags).)
Public methodGetMembers()Returns all the public members of the current Type. (Inherited from Type.)
Public methodGetMembers(BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetMembers(BindingFlags).)
Public methodGetMethod(String)Searches for the public method with the specified name. (Inherited from Type.)
Public methodGetMethod(String, BindingFlags)Searches for the specified method, using the specified binding constraints. (Inherited from Type.)
Public methodGetMethod(String, Type[])Searches for the specified public method whose parameters match the specified argument types. (Inherited from Type.)
Public methodGetMethod(String, Type[], ParameterModifier[])Searches for the specified public method whose parameters match the specified argument types and modifiers. (Inherited from Type.)
Public methodGetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])Searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.)
Public methodGetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])Searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention. (Inherited from Type.)
Protected methodGetMethodImplWhen overridden in a derived class, searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention. (Inherited from Type.)
Public methodGetMethods()Returns all the public methods of the current Type. (Inherited from Type.)
Public methodGetMethods(BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetMethods(BindingFlags).)
Public methodGetNestedType(String)Searches for the public nested type with the specified name. (Inherited from Type.)
Public methodGetNestedType(String, BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetNestedType(String, BindingFlags).)
Public methodGetNestedTypes()Returns the public types nested in the current Type. (Inherited from Type.)
Public methodGetNestedTypes(BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetNestedTypes(BindingFlags).)
Public methodGetProperties()Returns all the public properties of the current Type. (Inherited from Type.)
Public methodGetProperties(BindingFlags)Not supported for incomplete generic type parameters. (Overrides Type.GetProperties(BindingFlags).)
Public methodGetProperty(String)Searches for the public property with the specified name. (Inherited from Type.)
Public methodGetProperty(String, BindingFlags)Searches for the specified property, using the specified binding constraints. (Inherited from Type.)
Public methodGetProperty(String, Type)Searches for the public property with the specified name and return type. (Inherited from Type.)
Public methodGetProperty(String, Type[])Searches for the specified public property whose parameters match the specified argument types. (Inherited from Type.)
Public methodGetProperty(String, Type, Type[])Searches for the specified public property whose parameters match the specified argument types. (Inherited from Type.)
Public methodGetProperty(String, Type, Type[], ParameterModifier[])Searches for the specified public property whose parameters match the specified argument types and modifiers. (Inherited from Type.)
Public methodGetProperty(String, BindingFlags, Binder, Type, Type[], ParameterModifier[])Searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.)
Protected methodGetPropertyImplWhen overridden in a derived class, searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.)
Public methodGetType()Gets the current Type. (Inherited from Type.)
Protected methodGetTypeCodeImplReturns the underlying type code of the specified Type. (Inherited from Type.)
Protected methodHasElementTypeImplWhen overridden in a derived class, implements the HasElementType property and determines whether the current Type encompasses or refers to another type; that is, whether the current Type is an array, a pointer, or is passed by reference. (Inherited from Type.)
Public methodInvokeMember(String, BindingFlags, Binder, Object, Object[])Invokes the specified member, using the specified binding constraints and matching the specified argument list. (Inherited from Type.)
Public methodInvokeMember(String, BindingFlags, Binder, Object, Object[], CultureInfo)Invokes the specified member, using the specified binding constraints and matching the specified argument list and culture. (Inherited from Type.)
Public methodInvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])Not supported for incomplete generic type parameters. (Overrides Type.InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]).)
Protected methodIsArrayImplWhen overridden in a derived class, implements the IsArray property and determines whether the Type is an array. (Inherited from Type.)
Public methodIsAssignableFromNot supported for incomplete generic type parameters. (Overrides Type.IsAssignableFrom(Type).)
Protected methodIsByRefImplWhen overridden in a derived class, implements the IsByRef property and determines whether the Type is passed by reference. (Inherited from Type.)
Protected methodIsCOMObjectImplWhen overridden in a derived class, implements the IsCOMObject property and determines whether the Type is a COM object. (Inherited from Type.)
Protected methodIsContextfulImplImplements the IsContextful property and determines whether the Type can be hosted in a context. (Inherited from Type.)
Public methodIsDefinedNot supported for incomplete generic type parameters. (Overrides MemberInfo.IsDefined(Type, Boolean).)
Public methodIsEnumDefinedReturns a value that indicates whether the specified value exists in the current enumeration type. (Inherited from Type.)
Public methodIsEquivalentToDetermines whether two COM types have the same identity and are eligible for type equivalence. (Inherited from Type.)
Public methodIsInstanceOfTypeDetermines whether the specified object is an instance of the current Type. (Inherited from Type.)
Protected methodIsMarshalByRefImplImplements the IsMarshalByRef property and determines whether the Type is marshaled by reference. (Inherited from Type.)
Protected methodIsPointerImplWhen overridden in a derived class, implements the IsPointer property and determines whether the Type is a pointer. (Inherited from Type.)
Protected methodIsPrimitiveImplWhen overridden in a derived class, implements the IsPrimitive property and determines whether the Type is one of the primitive types. (Inherited from Type.)
Public methodIsSubclassOfNot supported for incomplete generic type parameters. (Overrides Type.IsSubclassOf(Type).)
Protected methodIsValueTypeImplImplements the IsValueType property and determines whether the Type is a value type; that is, not a class or an interface. (Inherited from Type.)
Public methodMakeArrayType()Returns the type of a one-dimensional array whose element type is the generic type parameter. (Overrides Type.MakeArrayType().)
Public methodMakeArrayType(Int32)Returns the type of an array whose element type is the generic type parameter, with the specified number of dimensions. (Overrides Type.MakeArrayType(Int32).)
Public methodMakeByRefTypeReturns a Type object that represents the current generic type parameter when passed as a reference parameter. (Overrides Type.MakeByRefType().)
Public methodMakeGenericTypeNot valid for incomplete generic type parameters. (Overrides Type.MakeGenericType(Type[]).)
Public methodMakePointerTypeReturns a Type object that represents a pointer to the current generic type parameter. (Overrides Type.MakePointerType().)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetBaseTypeConstraintSets the base type that a type must inherit in order to be substituted for the type parameter.
Public methodSetCustomAttribute(CustomAttributeBuilder)Set a custom attribute using a custom attribute builder.
Public methodSetCustomAttribute(ConstructorInfo, Byte[])Sets a custom attribute using a specified custom attribute blob.
Public methodSetGenericParameterAttributesSets the variance characteristics and special constraints of the generic parameter, such as the parameterless constructor constraint.
Public methodSetInterfaceConstraintsSets the interfaces a type must implement in order to be substituted for the type parameter.
Public methodToStringReturns a string representation of the current generic type parameter. (Overrides Type.ToString().)
Top

  NameDescription
Explicit interface implemetationPrivate method_MemberInfo.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from MemberInfo.)
Explicit interface implemetationPrivate method_MemberInfo.GetTypeGets a Type object representing the MemberInfo class. (Inherited from MemberInfo.)
Explicit interface implemetationPrivate method_MemberInfo.GetTypeInfoRetrieves the type information for an object, which can then be used to get the type information for an interface. (Inherited from MemberInfo.)
Explicit interface implemetationPrivate method_MemberInfo.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from MemberInfo.)
Explicit interface implemetationPrivate method_MemberInfo.InvokeProvides access to properties and methods exposed by an object. (Inherited from MemberInfo.)
Explicit interface implemetationPrivate method_Type.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Type.)
Explicit interface implemetationPrivate method_Type.GetTypeInfoRetrieves the type information for an object, which can then be used to get the type information for an interface. (Inherited from Type.)
Explicit interface implemetationPrivate method_Type.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Type.)
Explicit interface implemetationPrivate method_Type.InvokeProvides access to properties and methods exposed by an object. (Inherited from Type.)
Top

You can get an array of GenericTypeParameterBuilder objects by using the TypeBuilder.DefineGenericParameters method to add type parameters to a dynamic type, thus making it a generic type, or by using the MethodBuilder.DefineGenericParameters method to add type parameters to a dynamic method. Use the GenericTypeParameterBuilder objects to add constraints to the type parameters. Constraints are of three kinds:

  • The base type constraint specifies that any type assigned to the generic type parameter must derive from a particular base type. Set this constraint by using the SetBaseTypeConstraint method.

  • An interface constraint specifies that any type assigned to the generic type parameter must implement a particular interface. Set the interface constraints by using the SetInterfaceConstraints method.

  • Special constraints specify that any type assigned to the generic type parameter must have a default constructor, must be a reference type, or must be a value type. Set the special constraints for a type parameter by using the SetGenericParameterAttributes method.

Interface constraints and special constraints cannot be retrieved using methods of the GenericTypeParameterBuilder class. Once you have created the generic type that contains the type parameters, you can use its Type object to reflect the constraints. Use the Type.GetGenericArguments method to get the type parameters, and for each type parameter use the Type.GetGenericParameterConstraints method to get the base type constraint and interface constraints, and the Type.GenericParameterAttributes property to get the special constraints.

The following code example creates a generic type with two type parameters, and saves them in the assembly GenericEmitExample1.dll. You can use the Ildasm.exe (MSIL Disassembler) to view the generated types. For a more detailed explanation of the steps involved in defining a dynamic generic type, see How to: Define a Generic Type with Reflection Emit.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft