Skip to content

Commit d4d7689

Browse files
author
ladeak
committed
Updating readme.
1 parent f05e8be commit d4d7689

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Readme.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ JsonMergePatch library helps to deserialize http requests' and responses' json b
1010

1111
JsonMergePatch library is based on C# source generators. For the http body content to be deserialized into a type, the SourceGenerator library generates helper classes. Helper classes are called Wrappers, capturing all the features of the type intended to be used for the deserialization. Once the request is deserialized into a Wrapper object, the object can be used to apply the patch on the user defined target object. The JsonMergePatch library is designed to be used with POCO classes and record types.
1212

13-
Source Generations requires Visual Studio 16.9 or later.
13+
Source Generations requires Visual Studio 17.12 or later.
1414

1515
Based on the given application type different packages may be installed from NuGet by running one or more of the following commands:
1616

@@ -24,7 +24,7 @@ dotnet add package LaDeak.JsonMergePatch.AspNetCore
2424

2525
1. Install AspNetCore package via NuGet
2626
1. Add the required usings
27-
1. Add a new controller with a parameter types ```Patch<T>``` where ```T``` is a custom target type chosen by the user
27+
1. Add a new controller with a parameter types ```Patch<T>``` where ```T``` is a custom target type chosen by the user. Make sure that `[Patchable]` is applied on the `T` target type.
2828
1. Extend application startup
2929

3030
### Install AspNetCore packages via NuGet
@@ -58,7 +58,7 @@ public WeatherForecast PatchForecast(Patch<WeatherForecast> input)
5858
}
5959
```
6060

61-
During build, the source generator scans for methods with type parameters of ```Patch<T>```. When such a parameter is found a Wrapper type is generated for ```T```. The base class of the generated type provides the necessary operations to work with the type.
61+
During build, the source generator scans types has `[Patchable]` attribute applied. When such a type is found a Wrapper type is generated for it.
6262

6363
### Extend application startup
6464

@@ -86,9 +86,7 @@ The AspNetCore input reader supports requests with ```application/merge-patch+js
8686

8787
### Patchable
8888

89-
Certain use-cases require to generate wrapper types with the source generation for assemblies that do not directly use `Patch<T>` (where T is the wrapped source type). This could be a reason for having separate assemblies for entity types, or because of the need of stacking multiple source generators on top of each other.
90-
In thie case types may be attributed with `[Patchable]` attribute:
91-
89+
To generate wrapper types with the source generation add the `[Patchable]` attribute:
9290
```csharp
9391
[Patchable]
9492
public class WeatherForecast
@@ -97,8 +95,6 @@ public class WeatherForecast
9795
}
9896
```
9997

100-
`[Patchable]` makes sure to generate wrapper types for source types not used in HTTP requests or method arguments of `Patch<T>`.
101-
10298
### Using it with System.Text.Json source generation
10399

104100
In order to use multiple source generators, we need to *stack* them. Today the only way to do it is by enforcing a build order between two projects, while adding the first source generator to the first project built, and the second one to the second project built. To make sure JsonMergePatch source generator works with System.Text.Json's source generator create two projects:

0 commit comments

Comments
 (0)