Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement text KeyValues 3 #61

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
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
e3058f0
Very rudimentary kv3 text parsing
xPaw Aug 5, 2022
e53d3a3
Basic test for flagged value
xPaw Aug 5, 2022
e850169
kv3 does not have includes
xPaw Aug 5, 2022
f4c1e44
kv3 does not have conditionals
xPaw Aug 5, 2022
4ee3e0d
Basic identifier read (flagged values)
xPaw Aug 5, 2022
81914ee
Support multiline strings
xPaw Aug 5, 2022
2f32032
Support multi line comments
xPaw Aug 5, 2022
5a6b236
Partial support for arrays
xPaw Aug 5, 2022
2d1e3bc
Add kv3 guids
xPaw Aug 5, 2022
89474a9
Parse kv3 header outside of the state machine
xPaw Aug 5, 2022
894892d
Add tests for header parsing
xPaw Aug 5, 2022
b117774
Add value type to debugger display
xPaw Aug 7, 2022
d691016
Parse basic types
xPaw Aug 7, 2022
19287e7
Add some text kv3 serialization support
xPaw Aug 7, 2022
11e6caa
Prepare kv flag handling
xPaw Aug 8, 2022
26c9b48
Use Valve's delimeters
xPaw Aug 8, 2022
3058adb
flag 4
xPaw Aug 9, 2022
16f64c8
case insensitive
xPaw Aug 9, 2022
9841535
Read single quoted strings, read flags, correctly detect identifiers
xPaw Aug 9, 2022
9f67d87
Support quoted keys
xPaw Aug 9, 2022
f8c0d44
still check for :
xPaw Aug 9, 2022
ca0d158
Remove InObjectBeforeValue state
xPaw Aug 9, 2022
30378fb
Write quoted keys when necessary; test objects
xPaw Aug 9, 2022
c087db8
Support escaping """
xPaw Aug 9, 2022
999d8a3
Parse binary blobs
xPaw Aug 9, 2022
5dc8e07
Changes for array
xPaw Aug 9, 2022
8325318
Add OnArrayStart/OnArrayEnd
xPaw Aug 10, 2022
7e9745c
Fix nested objects/arrays in arrays
xPaw Aug 10, 2022
914b273
Some preparation for kv flags
xPaw Aug 10, 2022
771c7db
Implement flags on objects/arrays
xPaw Aug 11, 2022
623174b
Serialize arrays and flags
xPaw Aug 11, 2022
38802eb
Test that we serialize to kv1 without flags and arrays
xPaw Aug 11, 2022
4d96f4c
Add expected array serialization
xPaw Aug 11, 2022
048513f
Simplify
xPaw Aug 11, 2022
eae477d
Put common token reader methods in one class
xPaw Aug 11, 2022
749a436
Put commas after objects and arrays in arrays
xPaw Dec 2, 2022
1f02799
Implement binary blobs
xPaw Dec 2, 2022
43a89dc
Remove unused usings
xPaw Dec 3, 2022
91b3e3e
Add test for nested arrays and objects
xPaw Dec 4, 2022
e186127
Implement ICollection/IList on KVArrayValue
xPaw Dec 4, 2022
ea6c2b0
Return KVFile from read header
xPaw Mar 3, 2023
1b248ae
Asset.Pass breaks analyzer
xPaw Mar 6, 2023
6e0bed3
Add test cases for different types of roots
xPaw Mar 6, 2023
66e3bd5
Add kv1 -> kv3 test
xPaw Apr 8, 2023
e4cf8fc
Improve kv3 key escaping
xPaw Jul 4, 2023
c298a54
Make KVFile extend KVObject
xPaw Jul 24, 2023
49a7c7d
Make KVFlag singular
xPaw Jul 24, 2023
bc47917
Rebase
xPaw Feb 9, 2024
45a0484
Add nuget publish
xPaw Mar 19, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ jobs:
files: artifacts/nupkg/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to NuGet Gallery
run: dotnet nuget push artifacts/nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
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