Skip to content

Commit 4d54e73

Browse files
committed
Update mediator.mdx
1 parent edf304a commit 4d54e73

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/content/docs/release-notes/mediator.mdx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,41 @@ import RN from '/src/components/ReleaseNote.astro';
1515
<RN type="enhancement">New RuntimeEventRegistration service that you can add event handlers to at runtime dynamically</RN>
1616
<RN type="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>
1717

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+
<MediatorHttp Include="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+
public partial class YourClass
41+
{
42+
public string? Name { get; set; }
43+
public int Age { 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+
1953
* Type must be partial
2054
* Keys support property names with formatting (like DateTime)
2155
* If no key is specified, it will generate a key format for all public instance properties that are not null

0 commit comments

Comments
 (0)