protected virtual void WriteConstraints(IndentedTextWriter writer, TypeParameter parameter) { // 1. class, struct, unmanaged // 2. base // 3. new() var orderedConstraints = new List <TypeParameterConstraint>(parameter.Constraints.Count); orderedConstraints.AddRange(parameter.Constraints.Where(p => p is ValueTypeTypeParameterConstraint || p is ClassTypeParameterConstraint || p is UnmanagedTypeParameterConstraint)); orderedConstraints.AddRange(parameter.Constraints.Where(p => p is BaseTypeParameterConstraint)); orderedConstraints.AddRange(parameter.Constraints.Where(p => p is ConstructorParameterConstraint)); writer.Write("where "); writer.Write(parameter.Name); writer.Write(" : "); Write(writer, orderedConstraints, ", "); }
public TypeReference(TypeParameter typeParameter) { _typeParameter = typeParameter ?? throw new ArgumentNullException(nameof(typeParameter)); }
public virtual void VisitTypeParameter(TypeParameter typeParameter) { VisitCollection(typeParameter.Constraints); }
public static bool HasConstraints(this TypeParameter parameter) { return(parameter.Constraints.Any()); }