Skip to content

Commit ba85be1

Browse files
authored
Merge pull request MessagePack-CSharp#1110 from neuecc/support-record
record note to ReadMe
2 parents e03f2aa + 433774b commit ba85be1

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
@@ -404,6 +404,16 @@ public struct Point
404404
}
405405
```
406406

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

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

0 commit comments

Comments
 (0)