AutoBogus
AutoBogus copied to clipboard
[Bug] recursive constructor parameter gives `StackOverflowException`
given:
[Fact]
public void AutoFakerTest()
{
// Arrange
var faker = new AutoFaker<MyResult>().Configure(c => c
.WithRecursiveDepth(1)
.WithTreeDepth(1));
// Act
var result = faker.Generate();
// Assert
result.Should().NotBeNull();
}
public class MyResult
{
public MyResult(IEnumerable<MyResult> innerResults)
{
InnerResults = innerResults;
}
public IEnumerable<MyResult> InnerResults { get; }
}
- expected: green test
-
current:
StackOverflowException
!
Version:
- AutoBugs 2.13.1
- Bogus: 33.1.1
Unfortunately I don't get a stacktrace :'( (Also not when debugging)
Hey @304NotModified
Thanks for your message and apologies for the delayed response. Working on several projects that are taking up 100% of my time at the moment.
I think you raise an interesting use case. We have checks in AutoBogus that will compares the current type to its parent and stop the recursion going past a certain depth. However, I don't think that check is performed on the generic type of a collection.
I will do some investigations and get a fix in place.
Nick.
@304NotModified Constructors with enumerable recursion is now tested and working in soenneker.utils.autobogus