public void SetGenericParameterConstraints(IEnumerable <Type> constraints)
        {
            ArgumentUtility.CheckNotNull("constraints", constraints);

            var cons = constraints.ToList().AsReadOnly();

            if (cons.Any(c => c.IsValueType || c == typeof(ValueType)))
            {
                throw new ArgumentException("A generic parameter cannot be constrained by a value type.", "constraints");
            }

            var baseTypes = cons.Where(c => c.IsClass && !c.IsGenericParameter).ToList();

            if (baseTypes.Count > 1)
            {
                throw new ArgumentException("A generic parameter cannot have multiple base constraints.", "constraints");
            }
            var baseType = baseTypes.SingleOrDefault();

            if (baseType != null)
            {
                if (_genericParameterAttributes.IsSet(GenericParameterAttributes.NotNullableValueTypeConstraint))
                {
                    throw new ArgumentException("A generic parameter cannot have a base constraint if the NotNullableValueTypeConstraint flag is set.", "constraints");
                }

                SetBaseType(baseType);
            }

            _constraints = cons;
        }
        public MutableGenericParameter(
            int position,
            string name,
            string @namespace,
            GenericParameterAttributes genericParameterAttributes)
            : base(name, @namespace, attributes: TypeAttributes.Public, genericTypeDefinition: null, typeArguments: EmptyTypes)
        {
            Assertion.IsTrue(position >= 0);

            _position = position;
            _genericParameterAttributes = genericParameterAttributes;

            var baseType = genericParameterAttributes.IsSet(GenericParameterAttributes.NotNullableValueTypeConstraint) ? typeof(ValueType) : typeof(object);

            SetBaseType(baseType);
        }