Fix MaxDepth when used with ToObject inside of a JsonConverter (#2505)

This commit is contained in:
James Newton-King
2021-03-31 15:57:25 +13:00
committed by GitHub
parent ae9fe44e13
commit f7e7bd05d9
11 changed files with 287 additions and 6 deletions
@@ -1776,6 +1776,45 @@ third line", jsonTextReader.Value);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
await ExceptionAssert.ThrowsAsync<JsonReaderException>(async () => await JToken.ReadFromAsync(reader, settings));
}
[Test]
public async Task MaxDepth_GreaterThanDefaultAsync()
{
string json = GetNestedJson(150);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
reader.MaxDepth = 150;
while (await reader.ReadAsync())
{
}
}
[Test]
public async Task MaxDepth_NullAsync()
{
string json = GetNestedJson(150);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
reader.MaxDepth = null;
while (await reader.ReadAsync())
{
}
}
[Test]
public async Task MaxDepth_MaxValueAsync()
{
string json = GetNestedJson(150);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
reader.MaxDepth = int.MaxValue;
while (await reader.ReadAsync())
{
}
}
}
}
#endif