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