Skip to content

Commit

Permalink
4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Havunen committed Oct 18, 2024
1 parent f61fd2c commit 2e496ef
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 25 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 4.0.0

**BREAKING CHANGE:** SystemTextJsonPatch now supports different property naming policies!
f.e. `JsonNamingPolicy.SnakeCaseLower`. Fixes https://github.com/Havunen/SystemTextJsonPatch/issues/36

- This means that the **path** and **from** of the system text json patch document needs to match the JSON serializer options property naming policy.
For example, if the JSON serializer options are set to use camelCase, the patch path should also be in camelCase.

**BREAKING CHANGE:** Exception types have been changed.

- `JsonPatchException` -base exception type now contains `FailedOperation` and `AffectedObject` properties.
These properties are populated with the failed operation when the operation is available.
This change is to provide more information about the failed operation and the affected object. Fixes: https://github.com/Havunen/SystemTextJsonPatch/issues/26
- `NotSupportedException` and `InvalidOperationException` are not thrown anymore. Instead, `JsonPatchException` is thrown with the appropriate message.
- `JsonPatchTestOperationException` is now thrown only when the test operation fails. Fixes https://github.com/Havunen/SystemTextJsonPatch/issues/22

## 3.3.0
- Adds support for `DenyPatch` attribute to deny access to annotated property https://github.com/Havunen/SystemTextJsonPatch/pull/34
- Internal dependencies updated
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ This test deserializes a JSON patch document of 8 operations and applies the cha

See [SystemTextJsonPatch.Benchmark](https://github.com/Havunen/SystemTextJsonPatch/tree/main/SystemTextJsonPatch.Benchmark) for more details.

BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.3880/23H2/2023Update/SunValley3)
BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4169/23H2/2023Update/SunValley3)
AMD Ryzen 9 5950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK 8.0.400-preview.0.24324.5
[Host] : .NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX2
Job-FECQKB : .NET 8.0.5 (8.0.524.21615), X64 RyuJIT AVX2
.NET SDK 9.0.100-rc.1.24452.12
[Host] : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2
Job-MZQQSH : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2

WarmupCount=2

| Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
|-------------------- |-----------:|----------:|----------:|-------:|-------:|----------:|
| SystemTextJsonPatch | 5.253 us | 0.0315 us | 0.0451 us | 0.3357 | - | 5.52 KB |
| MarvinJsonPatch | 830.553 us | 9.1462 us | 7.6375 us | 5.8594 | 3.9063 | 104.82 KB |
| AspNetCoreJsonPatch | 18.078 us | 0.1070 us | 0.0948 us | 2.9297 | 0.0610 | 48.35 KB |
| SystemTextJsonPatch | 4.297 us | 0.0364 us | 0.0340 us | 0.2975 | - | 4.98 KB |
| MarvinJsonPatch | 764.999 us | 9.9837 us | 8.3368 us | 3.9063 | 1.9531 | 95.41 KB |
| AspNetCoreJsonPatch | 16.692 us | 0.0996 us | 0.0932 us | 2.6550 | 0.0610 | 43.55 KB |
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ public void GlobalSetup()
};
}

public static string DeserializePatchDocJson = string.Format("[" + "{{\"op\": \"replace\", \"path\": \"number\", \"value\": 86632}}," +
"{{\"op\": \"replace\", \"path\": \"text\", \"value\": \"testing-performance\"}}," +
"{{\"op\": \"add\", \"path\": \"amount\", \"value\": 86632.172712}}," +
"{{\"op\": \"replace\", \"path\": \"amount2\", \"value\": null}}," +
"{{\"op\": \"replace\", \"path\": \"subTestModel\", \"value\": {{\"id\": 91117, \"data\": 78}}}}," +
"{{\"op\": \"test\", \"path\": \"number\", \"value\": 86632}}," +
"{{\"op\": \"test\", \"path\": \"text\", \"value\": \"testing-performance\"}}," +
"{{\"op\": \"copy\", \"path\": \"amount2\", \"from\": \"amount\"}}," +
"{{\"op\": \"remove\", \"path\": \"text\"}}" + "]");
public static string DeserializePatchDocJson = string.Format(
"[" +
"{{\"op\": \"replace\", \"path\": \"Number\", \"value\": 86632}}," +
"{{\"op\": \"replace\", \"path\": \"Text\", \"value\": \"testing-performance\"}}," +
"{{\"op\": \"add\", \"path\": \"Amount\", \"value\": 86632.172712}}," +
"{{\"op\": \"replace\", \"path\": \"Amount2\", \"value\": null}}," +
"{{\"op\": \"replace\", \"path\": \"SubTestModel\", \"value\": {{\"Id\": 91117, \"Data\": 78}}}}," +
"{{\"op\": \"test\", \"path\": \"Number\", \"value\": 86632}}," +
"{{\"op\": \"copy\", \"path\": \"Amount2\", \"from\": \"Amount\"}}," +
"{{\"op\": \"remove\", \"path\": \"Text\"}}" +
"]"
);


[Benchmark]
Expand Down
16 changes: 8 additions & 8 deletions SystemTextJsonPatch.Console/DeserializeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ public class DeserializeTest
{
public static string DeserializePatchDocJson = string.Format(
"[" +
"{{\"op\": \"replace\", \"path\": \"number\", \"value\": 86632}}," +
"{{\"op\": \"replace\", \"path\": \"text\", \"value\": \"testing-performance\"}}," +
"{{\"op\": \"add\", \"path\": \"amount\", \"value\": 86632.172712}}," +
"{{\"op\": \"replace\", \"path\": \"amount2\", \"value\": null}}," +
"{{\"op\": \"replace\", \"path\": \"subTestModel\", \"value\": {{\"id\": 91117, \"data\": 78}}}}," +
"{{\"op\": \"test\", \"path\": \"number\", \"value\": 86632}}," +
"{{\"op\": \"copy\", \"path\": \"amount2\", \"from\": \"amount\"}}," +
"{{\"op\": \"remove\", \"path\": \"text\"}}" +
"{{\"op\": \"replace\", \"path\": \"Number\", \"value\": 86632}}," +
"{{\"op\": \"replace\", \"path\": \"Text\", \"value\": \"testing-performance\"}}," +
"{{\"op\": \"add\", \"path\": \"Amount\", \"value\": 86632.172712}}," +
"{{\"op\": \"replace\", \"path\": \"Amount2\", \"value\": null}}," +
"{{\"op\": \"replace\", \"path\": \"SubTestModel\", \"value\": {{\"Id\": 91117, \"Data\": 78}}}}," +
"{{\"op\": \"test\", \"path\": \"Number\", \"value\": 86632}}," +
"{{\"op\": \"copy\", \"path\": \"Amount2\", \"from\": \"Amount\"}}," +
"{{\"op\": \"remove\", \"path\": \"Text\"}}" +
"]"
);

Expand Down
2 changes: 1 addition & 1 deletion SystemTextJsonPatch/SystemTextJsonPatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;json;jsonpatch;system.text.json;rfc6902;</PackageTags>
<LangVersion>12</LangVersion>
<Version>3.3.0</Version>
<Version>4.0.0</Version>
<RepositoryUrl>https://github.com/Havunen/SystemTextJsonPatch.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<AnalysisLevel>8.0-all</AnalysisLevel>
Expand Down

0 comments on commit 2e496ef

Please sign in to comment.