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, ", ");
        }
Exemplo n.º 2
0
 public TypeReference(TypeParameter typeParameter)
 {
     _typeParameter = typeParameter ?? throw new ArgumentNullException(nameof(typeParameter));
 }
Exemplo n.º 3
0
 public virtual void VisitTypeParameter(TypeParameter typeParameter)
 {
     VisitCollection(typeParameter.Constraints);
 }
Exemplo n.º 4
0
 public static bool HasConstraints(this TypeParameter parameter)
 {
     return(parameter.Constraints.Any());
 }