private void DefineGenericParameter(InternalGenericParameter parameter, GenericTypeParameterBuilder builder) { // Set base type constraint if (parameter.BaseType != TypeSystemServices.ObjectType) { builder.SetBaseTypeConstraint(GetSystemType(parameter.BaseType)); } // Set interface constraints Type[] interfaceTypes = Array.ConvertAll<IType, Type>( parameter.GetInterfaces(), GetSystemType); builder.SetInterfaceConstraints(interfaceTypes); // Set special attributes GenericParameterAttributes attributes = GenericParameterAttributes.None; if (parameter.IsClass) attributes |= GenericParameterAttributes.ReferenceTypeConstraint; if (parameter.IsValueType) attributes |= GenericParameterAttributes.NotNullableValueTypeConstraint; if (parameter.MustHaveDefaultConstructor) attributes |= GenericParameterAttributes.DefaultConstructorConstraint; builder.SetGenericParameterAttributes(attributes); }