It seems that the recursive depth safe mechanism doesn't work on records.
Generating an instance of this record as follows
public record FakeChild (string Name, List<FakeChild>? C);
var child = new AutoFaker<FakeChild>().Configure(x => x.WithTreeDepth(1).WithRecursiveDepth(1)).Generate();
will cause a StackOverflow exception.
The only way around this is to move the Children property to the Record body as follows:
public record FakeChild (string Name)
{
List<FakeChild> Children { get; set; }
}
While that works, it defies the purpose of using a Record instead of a Class.
It seems that the recursive depth safe mechanism doesn't work on records. Generating an instance of this record as follows
will cause a StackOverflow exception.
The only way around this is to move the
Children
property to the Record body as follows:While that works, it defies the purpose of using a Record instead of a Class.