Merge branch 'release/2.2'
This commit is contained in:
commit
891ae28851
|
|
@ -9,7 +9,7 @@
|
|||
<MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>3.0.0-alpha1-10549</MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>
|
||||
<MicrosoftNETCoreApp20PackageVersion>2.0.9</MicrosoftNETCoreApp20PackageVersion>
|
||||
<MicrosoftNETCoreApp21PackageVersion>2.1.3</MicrosoftNETCoreApp21PackageVersion>
|
||||
<MicrosoftNETCoreApp22PackageVersion>2.2.0-preview2-26905-02</MicrosoftNETCoreApp22PackageVersion>
|
||||
<MicrosoftNETCoreApp22PackageVersion>2.2.0-preview3-26927-02</MicrosoftNETCoreApp22PackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
|
||||
<MoqPackageVersion>4.9.0</MoqPackageVersion>
|
||||
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Microsoft.AspNetCore.JsonPatch.Adapters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
|
|
@ -56,6 +55,13 @@ namespace Microsoft.AspNetCore.JsonPatch.Internal
|
|||
adapter = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we hit a null on an interior segment then we need to stop traversing.
|
||||
if (next == null)
|
||||
{
|
||||
adapter = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
target = next;
|
||||
adapter = SelectAdapter(target);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Dynamic;
|
||||
using Microsoft.AspNetCore.JsonPatch.Exceptions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.JsonPatch.IntegrationTests
|
||||
|
|
@ -124,5 +126,30 @@ namespace Microsoft.AspNetCore.JsonPatch.IntegrationTests
|
|||
Assert.Equal(newGuid, targetObject.GuidValue);
|
||||
}
|
||||
|
||||
// https://github.com/aspnet/AspNetCore/issues/3634
|
||||
[Fact]
|
||||
public void Regression_AspNetCore3634()
|
||||
{
|
||||
// Assert
|
||||
var document = new JsonPatchDocument();
|
||||
document.Move("/Object", "/Object/goodbye");
|
||||
|
||||
dynamic @object = new ExpandoObject();
|
||||
@object.hello = "world";
|
||||
|
||||
var target = new Regression_AspNetCore3634_Object();
|
||||
target.Object = @object;
|
||||
|
||||
// Act
|
||||
var ex = Assert.Throws<JsonPatchException>(() => document.ApplyTo(target));
|
||||
|
||||
// Assert
|
||||
Assert.Equal("For operation 'move', the target location specified by path '/Object/goodbye' was not found.", ex.Message);
|
||||
}
|
||||
|
||||
private class Regression_AspNetCore3634_Object
|
||||
{
|
||||
public dynamic Object { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,6 +205,22 @@ namespace Microsoft.AspNetCore.JsonPatch.Internal
|
|||
Assert.IsType<PocoAdapter>(adapter);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Visit_NullInteriorTarget_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var visitor = new ObjectVisitor(new ParsedPath("/States/0"), new DefaultContractResolver());
|
||||
|
||||
// Act
|
||||
object target = new Class1() { States = null, };
|
||||
var visitStatus = visitor.TryVisit(ref target, out var adapter, out var message);
|
||||
|
||||
// Assert
|
||||
Assert.False(visitStatus);
|
||||
Assert.Null(adapter);
|
||||
Assert.Null(message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Visit_NullTarget_ReturnsNullAdapter()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue