Reputation: 1951
I'm serializing a linked list and when deserializing I get the following error.
Google.Protobuf.InvalidProtocolBufferException: 'Protocol message had too many levels of nesting. May be malicious. Use CodedInputStream.SetRecursionLimit() to increase the depth limit.'
I couldn't find a lot of documentation on how to fix this.
Upvotes: 1
Views: 1340
Reputation: 3178
The recursion limit can be set by using CodedInputStream.CreateWithLimits
:
public static CodedInputStream CreateWithLimits(Stream input, int sizeLimit, int recursionLimit)
Note the default recursion is a depth of 64. See the source here.
Edit: Can you post your model for your linked list items? You might be able to add in some flattening behavior before serialization is performed.
Upvotes: 1