Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record with nested children of the same type as the parent causes StackOverflow #89

Open
nour-s opened this issue Aug 16, 2022 · 2 comments

Comments

@nour-s
Copy link

nour-s commented Aug 16, 2022

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.

@soenneker
Copy link

I'm sure you have moved past this, but I will fix this in soenneker.utils.autobogus shortly

@soenneker
Copy link

soenneker.utils.autobogus now supports classes and records with parameters of the same declaring type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants