Fixed merging with self bug.
This commit is contained in:
committed by
James Newton-King
parent
07c34f24cb
commit
da0f0d8dd1
@@ -46,6 +46,14 @@ namespace Newtonsoft.Json.Tests.Linq
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MergeTests : TestFixtureBase
|
public class MergeTests : TestFixtureBase
|
||||||
{
|
{
|
||||||
|
[Test]
|
||||||
|
public void MergeSelf()
|
||||||
|
{
|
||||||
|
var a = new JArray { "1", "2" };
|
||||||
|
a.Merge(a, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace });
|
||||||
|
Assert.AreEqual(a, new JArray { "1", "2" });
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void MergeNullString()
|
public void MergeNullString()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1164,6 +1164,8 @@ namespace Newtonsoft.Json.Linq
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case MergeArrayHandling.Replace:
|
case MergeArrayHandling.Replace:
|
||||||
|
if (target == content)
|
||||||
|
break;
|
||||||
target.ClearItems();
|
target.ClearItems();
|
||||||
foreach (JToken item in content)
|
foreach (JToken item in content)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user