Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
de9f476
Very rudimentary kv3 text parsing
xPaw Aug 5, 2022
88db581
Basic test for flagged value
xPaw Aug 5, 2022
b958d6b
kv3 does not have includes
xPaw Aug 5, 2022
0766277
kv3 does not have conditionals
xPaw Aug 5, 2022
c8696fe
Basic identifier read (flagged values)
xPaw Aug 5, 2022
84e5f2c
Support multiline strings
xPaw Aug 5, 2022
17875ba
Support multi line comments
xPaw Aug 5, 2022
dafef2e
Partial support for arrays
xPaw Aug 5, 2022
68dd620
Add kv3 guids
xPaw Aug 5, 2022
5d26bff
Parse kv3 header outside of the state machine
xPaw Aug 5, 2022
8971034
Add tests for header parsing
xPaw Aug 5, 2022
3530dae
Add value type to debugger display
xPaw Aug 7, 2022
5cf4b60
Parse basic types
xPaw Aug 7, 2022
934033b
Add some text kv3 serialization support
xPaw Aug 7, 2022
0923322
Prepare kv flag handling
xPaw Aug 8, 2022
08b6123
Use Valve's delimeters
xPaw Aug 8, 2022
b2f4b4d
flag 4
xPaw Aug 9, 2022
694489d
case insensitive
xPaw Aug 9, 2022
f61912e
Read single quoted strings, read flags, correctly detect identifiers
xPaw Aug 9, 2022
585b8a2
Support quoted keys
xPaw Aug 9, 2022
7a819d2
still check for :
xPaw Aug 9, 2022
85ce390
Remove InObjectBeforeValue state
xPaw Aug 9, 2022
bed2bb8
Write quoted keys when necessary; test objects
xPaw Aug 9, 2022
c7bbcf3
Support escaping """
xPaw Aug 9, 2022
b29f10c
Parse binary blobs
xPaw Aug 9, 2022
d700bbd
Changes for array
xPaw Aug 9, 2022
df76133
Add OnArrayStart/OnArrayEnd
xPaw Aug 10, 2022
97c5cbd
Fix nested objects/arrays in arrays
xPaw Aug 10, 2022
ae3e24c
Some preparation for kv flags
xPaw Aug 10, 2022
c0381cc
Implement flags on objects/arrays
xPaw Aug 11, 2022
a18b987
Serialize arrays and flags
xPaw Aug 11, 2022
bd3d447
Test that we serialize to kv1 without flags and arrays
xPaw Aug 11, 2022
b1fa5d2
Add expected array serialization
xPaw Aug 11, 2022
f709b88
Simplify
xPaw Aug 11, 2022
d517ae9
Put common token reader methods in one class
xPaw Aug 11, 2022
ecd2dde
Put commas after objects and arrays in arrays
xPaw Dec 2, 2022
52af7c2
Implement binary blobs
xPaw Dec 2, 2022
d800e2e
Remove unused usings
xPaw Dec 3, 2022
df7d437
Add test for nested arrays and objects
xPaw Dec 4, 2022
cc6b98d
Implement ICollection/IList on KVArrayValue
xPaw Dec 4, 2022
080a360
Return KVFile from read header
xPaw Mar 3, 2023
2057eba
Asset.Pass breaks analyzer
xPaw Mar 6, 2023
4882f3d
Add test cases for different types of roots
xPaw Mar 6, 2023
8bbccd7
Add kv1 -> kv3 test
xPaw Apr 8, 2023
5911cc6
Improve kv3 key escaping
xPaw Jul 4, 2023
0a61d2d
Make KVFile extend KVObject
xPaw Jul 24, 2023
4101c38
Make KVFlag singular
xPaw Jul 24, 2023
5d45a35
Rebase
xPaw Feb 9, 2024
196429d
Fix
xPaw Apr 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static IEnumerable ToStringTestCases
{
yield return new TestCaseData(new KVObject("a", "blah").Value).Returns("blah");
yield return new TestCaseData(new KVObject("a", "yay").Value).Returns("yay");
yield return new TestCaseData(new KVObject("a", []).Value).Returns("[Collection]").SetName("{m} - Empty Collection");
yield return new TestCaseData(new KVObject("a", Enumerable.Empty<KVObject>()).Value).Returns("[Collection]").SetName("{m} - Empty Collection");
yield return new TestCaseData(new KVObject("a", [new KVObject("boo", "aah")]).Value).Returns("[Collection]").SetName("{m} - Collection With Value");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Keep intended line endings to test parser
*.kv3 eol=lf
*_crlf.kv3 eol=crlf
33 changes: 33 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Test Data/TextKV3/array.kv3
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
arrayValue =
[
"a",
"b",
]
arrayOnSingleLine = [ 16.7551, 20.3763, 19.6448 ]
arrayNoSpace=[1.3763,19.6448]
arrayMixedTypes =
[
"a",
1,
true,
false,
null,
{
foo = "bar"
},
[
1, 3, 3, 7
],
#[
11 FF
],
resource:"hello.world",
"""
multiline
string
""",
-69.420
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
arrayValue = {
"0" = "a"
"1" = "b"
}
arrayOnSingleLine = {
"0" = 16.7551
"1" = 20.3763
"2" = 19.6448
}
arrayNoSpace = {
"0" = 1.3763
"1" = 19.6448
}
arrayMixedTypes = {
"0" = "a"
"1" = "1"
"2" = "True"
"3" = "False"
"4" = ""
"5" = {
foo = "bar"
}
"6" = {
"0" = "1"
"1" = "3"
"2" = "3"
"3" = "7"
}
"7" = "11 FF"
"8" = "hello.world"
"9" = """
multiline
string
"""
"10" = -69.42
}
test = "success"
test = "success"
}
44 changes: 44 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Test Data/TextKV3/array_kv1.vdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"root"
{
"arrayValue"
{
"0" "a"
"1" "b"
}
"arrayOnSingleLine"
{
"0" "16.7551"
"1" "20.3763"
"2" "19.6448"
}
"arrayNoSpace"
{
"0" "1.3763"
"1" "19.6448"
}
"arrayMixedTypes"
{
"0" "a"
"1" "1"
"2" "True"
"3" "False"
"4" ""
"5"
{
"foo" "bar"
}
"6"
{
"0" "1"
"1" "3"
"2" "3"
"3" "7"
}
"7" "11 FF"
"8" "hello.world"
"9" "multiline
string"
"10" "-69.42"
}
"test" "success"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
array = [
1,
2,
3,
{
array2 = [
4,
5,
6,
{
something = "something"
array3 = [
7,
8,
9,
]
test = "abc"
},
10,
]
test2 = "def"
},
"string",
11,
12,
[
13,
14,
15,
[
16,
17,
18,
],
],
19,
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
arrayValue = [
"a",
"b",
]
arrayOnSingleLine = [
16.7551,
20.3763,
19.6448,
]
arrayNoSpace = [
1.3763,
19.6448,
]
arrayMixedTypes = [
"a",
1,
true,
false,
null,
{
foo = "bar"
},
[
1,
3,
3,
7,
],
#[
11 FF
],
resource:"hello.world",
"""
multiline
string
""",
-69.42,
]
test = "success"
}
4 changes: 4 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Test Data/TextKV3/basic.kv3
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
foo = "bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
array =
#[
00 11 22 33 44 55 66 77 88 99
AA BB CC DD FF
]
}
10 changes: 10 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Test Data/TextKV3/comments.kv3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
// single line comment
/* multi
line
comment */
foo = "bar" // comment after
one = /* comment in between */ /* another comment in between */ "1" /* comment after */
two /* comment in between */ = "2" /* comment after */
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
foo = resource:"bar"
bar = resource|"foo"
uppercase = RESOURCE:"foo"
flaggedNumber = panorama:-1234
multipleFlags = resource:resource_name|subclass:"cool value"
soundEvent = soundEvent:"event sound"
noFlags = 5

flaggedObject = panorama:{
1 = soundEvent:"test1"
2 = "test2"
3 = subclass:[
"test3"
]
4 = resource_name:"test4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
foo = "bar"
bar = "foo"
uppercase = "foo"
flaggedNumber = "-1234"
multipleFlags = "cool value"
soundEvent = "event sound"
noFlags = "5"
flaggedObject = {
"1" = "test1"
"2" = "test2"
"3" = {
"0" = "test3"
}
"4" = "test4"
}
test = "success"
test = "success"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"root"
{
"foo" "bar"
"bar" "foo"
"uppercase" "foo"
"flaggedNumber" "-1234"
"multipleFlags" "cool value"
"soundEvent" "event sound"
"noFlags" "5"
"flaggedObject"
{
"1" "test1"
"2" "test2"
"3"
{
"0" "test3"
}
"4" "test4"
}
"test" "success"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
foo = resource:"bar"
bar = resource:"foo"
uppercase = resource:"foo"
flaggedNumber = panorama:-1234
multipleFlags = resource|resource_name|subclass:"cool value"
soundEvent = soundevent:"event sound"
noFlags = 5
flaggedObject = panorama:{
"1" = soundevent:"test1"
"2" = "test2"
"3" = subclass:[
"test3",
]
"4" = resource_name:"test4"
}
test = "success"
}
13 changes: 13 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Test Data/TextKV3/multiline.kv3
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
multiLineStringValue = """
First line of a multi-line string literal.
Second line of a multi-line string literal.
"""
multiLineWithQuotesInside = """
hmm this """is awkward
\""" yes
"""
singleQuotesButWithNewLineAnyway = "hello
valve"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
multiLineStringValue = """
First line of a multi-line string literal.
Second line of a multi-line string literal.
"""
}
9 changes: 9 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Test Data/TextKV3/object.kv3
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
a = {
foo = "bar"
b = {
c = "d"
}
}
}
23 changes: 23 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Test Data/TextKV3/root_array.kv3
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
[
"a",
1,
true,
false,
null,
{
foo = "bar"
},
[
1, 3, 3, 7
],
#[
11 FF
],
resource:"hello.world",
"""
multiline
string
""",
-69.420
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
#[
00 11 22 33 44 55 66 77 88 99
AA BB CC DD FF
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
panorama:{
foo = resource:"bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
resource:"cool_resource.txt"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
-1337.401
Loading
Loading