For the reasons unknown, Add
method doesn't use type parameter name then it's passed as a Type
type, but it will generate them from a string. Apparently difference is in the CodeTypeReference
class constructor (which is ultimate item type in Constraints
collection). So
codeTypeParameter.Constraints.Add(constraint.ToString());
should give you an expected result.