Class EnumerableFavoringConstructorQuery

Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll

Selects public constructors ordered so that any constructor with arguments matching IEnumerable%601 are selected before any other public constructor.

public class EnumerableFavoringConstructorQuery : IMethodQuery

Inheritance

objectEnumerableFavoringConstructorQuery

Implements

IMethodQuery

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Remarks

The main target of this IMethodQuery implementation is to pick IEnumerable%7b%600%7d) before any other constructor. This can be used to populate a list instance with a sequence of items.

Constructors

EnumerableFavoringConstructorQuery()

public EnumerableFavoringConstructorQuery()

Methods

SelectMethods(Type)

Selects the constructors for the supplied type.

public IEnumerable<IMethod> SelectMethods(Type type)

Parameters

type Type

The type.

Returns

IEnumerable<IMethod>

All public constructors for type, giving priority to any constructor with one or more IEnumerable%601 arguments.

Remarks

Given several constructors, this implementation will favor those constructors with arguments that matches `IEnumerable%601`, where T is the item type of type, if it's generic. Constructors with most matching arguments are returned before constructors with less matching arguments.

Any other constructors are returned with the most modest constructors first.

See Also

EnumerableFavoringConstructorQuery