Skip to content

Commit b1f0233

Browse files
committed
Add source-gen support for init and required members
Fix #114.
1 parent c54721e commit b1f0233

File tree

4 files changed

+400
-60
lines changed

4 files changed

+400
-60
lines changed

site/docs/serialization.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ public sealed class DatabaseConfig
256256
```
257257

258258
If `host` or `port` is missing from the TOML input, `TomlException` is thrown.
259+
Source-generated contexts also honor the C# `required` keyword and `init` accessors during deserialization.
259260

260261
### Example: constructor-based deserialization
261262

site/docs/source-generation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ internal partial class MyTomlContext : TomlSerializerContext { }
3636
The generator produces a `Default` singleton and a typed [`TomlTypeInfo<T>`](xref:Tomlyn.TomlTypeInfo`1) property for each root.
3737
Nested types referenced by the root are discovered transitively - you only need to annotate top-level types.
3838
Set [`TomlSerializableAttribute.TypeInfoPropertyName`](xref:Tomlyn.Serialization.TomlSerializableAttribute.TypeInfoPropertyName) when you want to customize the generated property name exposed by the context.
39+
Source-generated deserialization also supports C# `init` and `required` members.
3940

4041
## Use generated metadata
4142

0 commit comments

Comments
 (0)