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

SerializerBuilder should take a Recursion Limit/maxRecursion as an argument #352

Closed
dbpiper opened this issue Oct 2, 2018 · 3 comments · Fixed by #353
Closed

SerializerBuilder should take a Recursion Limit/maxRecursion as an argument #352

dbpiper opened this issue Oct 2, 2018 · 3 comments · Fixed by #353

Comments

@dbpiper
Copy link

dbpiper commented Oct 2, 2018

Currently the Recursion Limit/maxRecursion for SerializerBuilder/objectGraphTraversalStrategyFactory seems to be hardcoded to 50.

This is quite inflexible. As it means that someone who happens to have a tree with a depth greater than 50 (for example an application I am writing: Kata) simply gets the error "Too much recursion when traversing the object graph." Ideally this would be simply changed to an optional argument in SerializerBuilder.

The 50 number is used
on what is currently line 72 in the SerializerBuilder constructor:
objectGraphTraversalStrategyFactory = (typeInspector, typeResolver, typeConverters) => new FullObjectGraphTraversalStrategy(typeInspector, typeResolver, 50, namingConvention ?? new NullNamingConvention());

Link to file with hard coded value: SerializerBuilder .

@aaubry
Copy link
Owner

aaubry commented Oct 2, 2018

I totally agree. I have a method named WithMaximumRecursion that allows you to specify the value for the limit.
A pre-release package should be available on NuGet soon. I would apreciate if you could try it and confirm if it addresses your needs. The version is 5.1.1-issue-352-max-recursion0504

@dbpiper
Copy link
Author

dbpiper commented Oct 3, 2018

Yep that fixes the depth issue!

@dbpiper dbpiper closed this as completed Oct 3, 2018
@dbpiper dbpiper reopened this Oct 3, 2018
@aaubry
Copy link
Owner

aaubry commented Oct 3, 2018

Release 5.2.0 includes these changes. It should be available in a few minutes.

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

Successfully merging a pull request may close this issue.

2 participants