You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/release-notes/mediator.mdx
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,41 @@ import RN from '/src/components/ReleaseNote.astro';
15
15
<RNtype="enhancement">New RuntimeEventRegistration service that you can add event handlers to at runtime dynamically</RN>
16
16
<RNtype="fix">Child context should not receive a copy of the parent's headers as this will crash things like caching for a child request</RN>
17
17
18
-
#### New Contract Key Generator
18
+
#### New JSON Converter Source Generator
19
+
This feature allows you to generate JSON converters at compile time instead of using reflection at runtime. This is especially useful for AOT scenarios like iOS and Blazor WebAssembly.
20
+
Unfortunately, we are unable to "piggyback" source generators (ours to System.Text.Json), so we found the easiest way to do this was to generate JSON converters, NOT the types emitted by the System.Text.Json source generator.
21
+
22
+
Setting JSON converters allow you to push JsonConverterAttribute on the type instead of having to pass around a centralized JSON context.
23
+
24
+
We have two flavours of JSON generation. The first one (and most importantly) is for our HTTP client code generation. NOTE that JsonConverter generation is NOT enabled by default yet.
25
+
26
+
```xml
27
+
<ItemGroup>
28
+
<MediatorHttpInclude="OpenApiRemote"
29
+
Uri="https://youruri"
30
+
GenerateJsonConverters="true"
31
+
Visible="false" />
32
+
</ItemGroup>
33
+
```
34
+
35
+
Secondly, there will be times for features such as offline data storage or caching where data needs to serialize down to disk. These types obviously aren't generated by our source generators and are likely
36
+
types you've created. We've created a secondary way to create JSON converters for your own types.
37
+
38
+
```csharp
39
+
[SourceGenerateJsonConverter]
40
+
publicpartialclassYourClass
41
+
{
42
+
publicstring? Name { get; set; }
43
+
publicintAge { get; set; }
44
+
}
45
+
```
46
+
47
+
NOTE: Your class must be partial and the attribute must be placed on the type directly.
48
+
49
+
50
+
#### New Contract Key Source Generator
51
+
This feature allows you to generate a contract key at compile time instead of using reflection at runtime. This is especially useful for AOT scenarios like iOS and Blazor WebAssembly.
52
+
19
53
* Type must be partial
20
54
* Keys support property names with formatting (like DateTime)
21
55
* If no key is specified, it will generate a key format for all public instance properties that are not null
0 commit comments