Class ThrowingRecursionHandler

Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll

Breaks a recursion by throwing a descriptive exception.

public class ThrowingRecursionHandler : IRecursionHandler

Inheritance

objectThrowingRecursionHandler

Implements

IRecursionHandler

Inherited Members

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

Constructors

ThrowingRecursionHandler()

public ThrowingRecursionHandler()

Methods

HandleRecursiveRequest(object, IEnumerable<object>)

Handles a recursive request.

public object HandleRecursiveRequest(object request, IEnumerable<object> recordedRequests)

Parameters

request object

The request causing the recursion.

recordedRequests IEnumerable<object>

Previously recorded, and yet unhandled, requests.

Returns

object

An object intended to break the recursion.

Remarks

This method is called when AutoFixture detects an infinite recursion. The request is the request that triggered the recursion detection; recordedRequests contains all previous, but still unhandled requests: the current call stack, if you will.

This implementation always throws a descriptive exception, instructing the user that the requested type contains a circular reference, and that this is bad API design. The message also contains instructions on how to move on.

Exceptions

ObjectCreationException

Always.

See Also

ThrowingRecursionHandler.HandleRecursiveRequest(object, IEnumerable<object>)