Skip to content

Commit e1ff45e

Browse files
committed
Do not sort object members by name (.NET 7 makes this declaration order)
Fixes #80
1 parent 6211bb9 commit e1ff45e

File tree

6 files changed

+46
-30
lines changed

6 files changed

+46
-30
lines changed

ValveKeyValue/ValveKeyValue.Test/Binary/BinaryObjectSerializationTypedTestCase.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@ public void SerializesToBinaryStructure()
2626
{
2727
0x00, // object: TestObject
2828
0x54, 0x65, 0x73, 0x74, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
29-
0x03, // float32: flt = 1234.5678f
30-
0x66, 0x6C, 0x74, 0x00,
31-
0x2B, 0x52, 0x9A, 0x44,
32-
0x02, // int32, i16 = 32767
33-
0x69, 0x31, 0x36, 0x00,
34-
0xFF, 0x7F, 0x00, 0x00,
35-
0x0A, // int64, i64 = 0x0102030405070809
36-
0x69, 0x36, 0x34, 0x00,
37-
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
38-
0x02, // int32: int = 0x10203040
39-
0x69, 0x6E, 0x74, 0x00,
40-
0x40, 0x30, 0x20, 0x10,
4129
0x01, // string: key = value
4230
0x6B, 0x65, 0x79, 0x00,
4331
0x76, 0x61, 0x6C, 0x75, 0x65, 0x00,
44-
0x01, // string_utf8: key_utf8 = 邪恶的战
32+
0x01, // string: key_utf8 = 邪恶的战
4533
0x6B, 0x65, 0x79, 0x5F, 0x75, 0x74, 0x66, 0x38, 0x00,
4634
0xE9, 0x82, 0xAA, 0xE6, 0x81, 0xB6, 0xE7, 0x9A, 0x84, 0xE6, 0x88, 0x98, 0x00,
47-
0x07, // uint64: lng = 0x8877665544332211
48-
0x6C, 0x6E, 0x67, 0x00,
49-
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
35+
0x02, // int32: int = 0x10203040
36+
0x69, 0x6E, 0x74, 0x00,
37+
0x40, 0x30, 0x20, 0x10,
38+
0x03, // float32: flt = 1234.5678f
39+
0x66, 0x6C, 0x74, 0x00,
40+
0x2B, 0x52, 0x9A, 0x44,
5041
0x04, // pointer: ptr = 0x12345678
5142
0x70, 0x74, 0x72, 0x00,
5243
0x78, 0x56, 0x34, 0x12,
44+
0x07, // uint64: lng = 0x8877665544332211
45+
0x6C, 0x6E, 0x67, 0x00,
46+
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
47+
0x0A, // int64: i64 = 0x0102030405060708
48+
0x69, 0x36, 0x34, 0x00,
49+
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
50+
0x02, // int32: i16 = 32767
51+
0x69, 0x31, 0x36, 0x00,
52+
0xFF, 0x7F, 0x00, 0x00,
5353
0x07, // uint64: u16 = 65535
5454
0x75, 0x31, 0x36, 0x00,
5555
0xFF, 0xFF, 0x00, 0x00,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"test"
22
{
3+
"Strings"
4+
{
5+
"0" "test"
6+
"1" "test"
7+
}
38
"Ints"
49
{
510
"0" "1"
611
"1" "2"
712
"2" "1"
813
}
9-
"Strings"
10-
{
11-
"0" "test"
12-
"1" "test"
13-
}
1414
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"test data"
2+
{
3+
"0"
4+
{
5+
"Name" "Dota 2"
6+
"Developer" "Valve Software"
7+
"description" "Dota 2 is a complex game where you get sworn at
8+
in Russian all the time."
9+
}
10+
"1"
11+
{
12+
"Name" "Team Fortress 2"
13+
"Developer" "Valve Software"
14+
"description" "Known as \"America's #1 war-themed hat simulator\", this game lets you wear stupid items while killing people."
15+
}
16+
}

ValveKeyValue/ValveKeyValue.Test/Test Data/Text/serialization_types_expected.vdf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
{
33
"0"
44
{
5-
"VByteEnum" "255"
6-
"VEnum" "1337"
7-
"VFlags" "10"
8-
"VFloat" "1234.5677"
5+
"VString" "Test String"
96
"VInt" "270544960"
107
"VLong" "72623859790382856"
11-
"VLongEnum" "72623859790382856"
12-
"VShortEnum" "-1"
13-
"VString" "Test String"
148
"VULong" "9833440827789222417"
9+
"VFloat" "1234.5677"
10+
"VEnum" "1337"
11+
"VFlags" "10"
12+
"VByteEnum" "255"
13+
"VShortEnum" "-1"
14+
"VLongEnum" "72623859790382856"
1515
"VULongEnum" "9833440827789222417"
1616
}
1717
}

ValveKeyValue/ValveKeyValue.Test/Text/ObjectSerializationTestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void CreatesTextDocument()
3333
text = reader.ReadToEnd();
3434
}
3535

36-
var expected = TestDataHelper.ReadTextResource("Text.serialization_expected.vdf");
36+
var expected = TestDataHelper.ReadTextResource("Text.object_serialization_expected.vdf");
3737
Assert.That(text, Is.EqualTo(expected));
3838
}
3939

ValveKeyValue/ValveKeyValue/ObjectCopier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static KVObject ConvertObjectToValue(
125125
}
126126
else
127127
{
128-
foreach (var member in reflector.GetMembers(objectType, managedObject).OrderBy(p => p.Name, StringComparer.InvariantCulture))
128+
foreach (var member in reflector.GetMembers(objectType, managedObject))
129129
{
130130
if (member.Value is null)
131131
{

0 commit comments

Comments
 (0)