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

InfiniteLoopException - Limit Depth? #65

Closed
ibebbs opened this issue Jan 25, 2021 · 5 comments · Fixed by #66 or #67
Closed

InfiniteLoopException - Limit Depth? #65

ibebbs opened this issue Jan 25, 2021 · 5 comments · Fixed by #66 or #67
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@ibebbs
Copy link

ibebbs commented Jan 25, 2021

Hi,

I have a very rich (broad and deep) object model for which I'm trying to generate test data. CreateAndFake is currently showing the best results with the least effort of any comparable library, but I'm running into an "InfiniteLoopException".

Now the error message provides a good explanation as to why I'm encountering the issue and my object model does have recursive types (a->b->c->a). However, as I don't really care about generating objects after the second generation (a->b) I was wondering whether it is possible to limit the depth of generator or simply ignore the "InfiniteLoopException" such that the generator continues to the next property (of whatever object it's generating) as if generation had completed successfully.

Hope thats clear??

I've tried looking into the Limiter implementation but it doesn't seem to be designed to handle this use case.

Anyway, thanks for the library. Really hope this issue can be resolved/worked around as the CreateAndFake looks very promising.

Cheers,
Ian

@Werebunny Werebunny self-assigned this Jan 27, 2021
@Werebunny Werebunny added bug Something isn't working question Further information is requested labels Jan 27, 2021
@Werebunny Werebunny added this to To do in Create & Track via automation Jan 27, 2021
@Werebunny
Copy link
Member

Hi, sorry you're facing issues.

It seems silly to ask since I haven't updated the library in awhile, but are you on the latest version 1.8.2? I ask because I added recursion loops in my last commit. To try and reproduce the issue, I created a sample object via properties A.B.C.A and could randomize it without issue. The mechanism for this is on the RandomizerChainer, which will add a recursive reference if the previous type has already been created.

Theoretically you shouldn't ever see the InfiniteLoopException, it means I missed a link in the creation chain and didn't set the parent correctly. I've located all the spots where that is seemingly possible, and have attempted a fix.

Nuget should have version 1.8.3 here soon, I'm hoping it fixes your issue. If not, I'll need more details over how your type chain that's triggering the exception appears. Like are collections involved, generics, abstract classes, delegates... ect. As long as I can reproduce the issue with a test model, I'll be able to get it fixed here for you.

@Werebunny Werebunny linked a pull request Jan 27, 2021 that will close this issue
@Werebunny Werebunny moved this from To do to In progress in Create & Track Jan 27, 2021
@ibebbs
Copy link
Author

ibebbs commented Jan 27, 2021

Hey, thanks for getting back to me. .

To answer your questions: Yes, I'm using version 1.8.2 and, while a rich object model, it is fairly simple so it does not use any (custom) generics, inheritance or delegates. It uses collections extensively and the issue I'm seeing involves a collection like so: a->ICollection<b>->c->a.

Hope that will provide some clues as to the nature of the issue. If not, let me know and I'll endeavour to reproduce the issue in a repository I can share.

Thanks again,
Ian

@Werebunny
Copy link
Member

Did you see if version 1.8.3 worked for you?

I made another branch here to attempt to replicate and solve the issue, you can view the test here:
https://github.com/CreateAndFake/CreateAndFake/blob/Fix-65-InfiniteChainFix/tests/CreateAndFakeTests/IssueReplication/InfiniteChainTests.cs

I did encounter an issue with cloning objects, but not in creating them. So if you don't mind checking the model and comparing with yours I would be grateful.

@ibebbs
Copy link
Author

ibebbs commented Jan 28, 2021

Hey, just updated to 1.8.3 and the InfiniteLoopException issue is gone. Great work, thanks!

I'll close this issue now but any interest in a PR to support Uri and DateTimeOffset creation / duplication? I'm using these types extensively and currently need to add custom Create/CopyHints to support them.

@Werebunny
Copy link
Member

I have added Uri and DateTimeOffset support in the default hints released on version 1.8.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
2 participants