-Changed JToken.Children to return an empty iterator rather than erroring
This commit is contained in:
@@ -148,11 +148,11 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Cannot access child value on Newtonsoft.Json.Linq.JValue.")]
|
||||
public void Children()
|
||||
{
|
||||
JValue v = new JValue(true);
|
||||
var c = v.Children();
|
||||
Assert.AreEqual(JEnumerable<JToken>.Empty, c);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="JToken"/> containing the child tokens of this <see cref="JToken"/>, in document order.</returns>
|
||||
public virtual JEnumerable<JToken> Children()
|
||||
{
|
||||
throw new InvalidOperationException("Cannot access child value on {0}.".FormatWith(CultureInfo.InvariantCulture, GetType()));
|
||||
return JEnumerable<JToken>.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user