-Added support for Serializable attribute and MemberSerialization.Fields

-Added support for ignoring properties with NonSerializable attribute
-Added MaxDepth to JsonReader/JsonSerializer/JsonSerializerSettings
This commit is contained in:
James Newton-King
2012-04-08 19:33:09 +12:00
parent 83618b1ea0
commit e3cec969ef
20 changed files with 620 additions and 118 deletions
@@ -44,6 +44,25 @@ namespace Newtonsoft.Json.Tests
[TestFixture]
public class JsonTextReaderTest : TestFixtureBase
{
[Test]
public void SurrogatePairValid()
{
string json = @"{ ""MATHEMATICAL ITALIC CAPITAL ALPHA"": ""\uD835\uDEE2"" }";
JsonTextReader reader = new JsonTextReader(new StringReader(json));
Assert.IsTrue(reader.Read());
Assert.IsTrue(reader.Read());
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.String, reader.TokenType);
string s = reader.Value.ToString();
StringInfo stringInfo = new StringInfo(s);
Assert.AreEqual(1, stringInfo.LengthInTextElements);
}
[Test]
public void CloseInput()
{
@@ -2195,6 +2214,26 @@ bye", reader.Value);
reader.Read();
}
[Test]
public void MaxDepth()
{
string json = "[[]]";
JsonTextReader reader = new JsonTextReader(new StringReader(json))
{
MaxDepth = 1
};
Assert.IsTrue(reader.Read());
ExceptionAssert.Throws<JsonReaderException>(
"This reader's MaxDepth of 1 has been exceeded.",
() =>
{
Assert.IsTrue(reader.Read());
});
}
[Test]
public void ReadingFromSlowStream()
{