Skip to content

Commit f2b42ec

Browse files
committed
ReadMe, record support
1 parent 0f7a371 commit f2b42ec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,16 @@ public struct Point
403403
}
404404
```
405405

406+
C# 9.0 record with primary constructor is similar immutable object, also supports serialize/deserialize.
407+
408+
```csharp
409+
// use key as property name
410+
[MessagePackObject(true)]public record Point(int X, int Y);
411+
412+
// use property: to set KeyAttribute
413+
[MessagePackObject] public record Point([property:Key(0)] int X, [property: Key(1)] int Y);
414+
```
415+
406416
## Serialization Callback
407417

408418
Objects implementing the `IMessagePackSerializationCallbackReceiver` interface will received `OnBeforeSerialize` and `OnAfterDeserialize` calls during serialization/deserialization.

0 commit comments

Comments
 (0)