Commit 8bebc56
Replace BinaryFormatter with DataContractSerializer (#641)
* Replace BinaryFormatter with DataContractSerializer
BinaryFormatter is deprecated in future .NET versions and may prevent
assemblies from unloading or return incorrect results.
Replaced with System.Runtime.Serialization.DataContractSerializer as
recommended for compatibility.
Changes:
- KdTree.cs: Replaced BinaryFormatter with DataContractSerializer in
SaveToFile and LoadFromFile methods
- KdTreeNode.cs: Added DataContract and DataMember attributes
- Added [DataContract] and [DataMember] attributes to all serialized classes
Related to SCP-1555
* Use binary XML format for DataContractSerializer
Switch from text XML to binary XML format using XmlDictionaryWriter.CreateBinaryWriter()
and XmlDictionaryReader.CreateBinaryReader(). This provides:
- Binary format similar to BinaryFormatter (more compact and efficient)
- Better performance for large KdTree data structures
- Still uses DataContractSerializer for CoreCLR compatibility
Note: This changes the file format. Existing serialized KdTree files will need to be regenerated.
---------
Co-authored-by: thomas-tu <45040865+thomas-tu@users.noreply.github.com>1 parent 41c5767 commit 8bebc56
2 files changed
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
370 | 376 | | |
371 | 377 | | |
372 | 378 | | |
373 | | - | |
| 379 | + | |
| 380 | + | |
374 | 381 | | |
375 | 382 | | |
376 | 383 | | |
| |||
578 | 585 | | |
579 | 586 | | |
580 | 587 | | |
581 | | - | |
| 588 | + | |
582 | 589 | | |
| 590 | + | |
583 | 591 | | |
584 | | - | |
585 | | - | |
| 592 | + | |
| 593 | + | |
586 | 594 | | |
587 | 595 | | |
588 | 596 | | |
589 | 597 | | |
590 | 598 | | |
591 | | - | |
| 599 | + | |
592 | 600 | | |
| 601 | + | |
593 | 602 | | |
594 | | - | |
| 603 | + | |
595 | 604 | | |
596 | 605 | | |
597 | 606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
21 | 24 | | |
| 25 | + | |
22 | 26 | | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
| 30 | + | |
25 | 31 | | |
| 32 | + | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
| |||
0 commit comments