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
@@ -1770,5 +1770,44 @@ third line", jsonTextReader.Value);
JToken.ReadFrom(reader, settings);
});
}
[Test]
public void MaxDepth_GreaterThanDefault()
{
string json = GetNestedJson(150);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
reader.MaxDepth = 150;
while (reader.Read())
{
}
}
[Test]
public void MaxDepth_Null()
{
string json = GetNestedJson(150);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
reader.MaxDepth = null;
while (reader.Read())
{
}
}
[Test]
public void MaxDepth_MaxValue()
{
string json = GetNestedJson(150);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
reader.MaxDepth = int.MaxValue;
while (reader.Read())
{
}
}
}
}