Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ public string op
}
}

[JsonPropertyName(nameof(from))]
public string from { get; set; }
#nullable enable
[JsonPropertyName(nameof(from)), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? from { get; set; }
#nullable restore

public OperationBase()
{
Expand All @@ -59,10 +61,4 @@ public OperationBase(string op, string path, string from)
this.path = path;
this.from = from;
}

public bool ShouldSerializeFrom()
{
return (OperationType == OperationType.Move
|| OperationType == OperationType.Copy);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.Operation<TModel>.Operation(string op, string path, string from, object value) -> void
~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.Operation<TModel>.Operation(string op, string path, string from) -> void
~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.from.get -> string
~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.from.set -> void
~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.op.get -> string
~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.op.set -> void
~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.OperationBase(string op, string path, string from) -> void
Expand All @@ -95,7 +94,6 @@ Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.Operation<TModel>.Opera
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.OperationBase() -> void
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.OperationType.get -> Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationType
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.ShouldSerializeFrom() -> bool
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationType
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationType.Add = 0 -> Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationType
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationType.Copy = 4 -> Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationType
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#nullable enable

Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.from.get -> string?
Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.from.set -> void
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,26 @@

return JsonSerializer.Serialize<JsonPatchDocument<SimpleObject>>(document, jsonSerializerOptions);
}

[Fact]
public void Serialization_ShouldExcludeFrom_WhenNullAndNotMoveOrCopy()
{
// Arrange
JsonPatchDocument patchDocument = new();
patchDocument.Add("/a/b/c", "foo");
patchDocument.Remove("/x/y/z");
patchDocument.Replace("/d/e", "bar");
patchDocument.Test("/f/e", "t1");

var json = JsonSerializer.Serialize(patchDocument);

// Assert
var expectedJson = """
[{"value":"foo","path":"/a/b/c","op":"add"},{"value":null,"path":"/x/y/z","op":"remove"},
{ "value":"bar","path":"/d/e","op":"replace"},{ "value":"t1","path":"/f/e","op":"test"}]
""";

// Act
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(expectedJson), JsonNode.Parse(json)));

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,41): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,71): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,41): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,71): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,41): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,71): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,41): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,71): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,41): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context

Check failure on line 278 in src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs#L278

src/Features/JsonPatch.SystemTextJson/test/JsonPatchDocumentTest.cs(278,71): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'JsonNode' does not exist in the current context
}
}
Loading