• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📃 Next-generation Valve's key value framework for .NET

Valve's KeyValue for .NET

Build Status (GitHub) NuGet Coverage Status

This library aims to be fully compatible with Valve's various implementations of KeyValues format parsing (believe us, it's not consistent).

KeyValues1

Used by Steam and the Source engine.

Deserializing text

Basic deserialization

var stream = File.OpenRead("file.vdf"); // or any other Stream

var kv = KVSerializer.Create(KVSerializationFormat.KeyValues1Text);
KVObject data = kv.Deserialize(stream);

Console.WriteLine(data["some key"]);

Typed deserialization

public class SimpleObject
{
	public string Name { get; set; }
	public string Value { get; set; }
}

var stream = File.OpenRead("file.vdf"); // or any other Stream

var kv = KVSerializer.Create(KVSerializationFormat.KeyValues1Text);
KVObject data = kv.Deserialize<SimpleObject>(stream);

Options

Deserialize method also accepts an KVSerializerOptions object.

By default, operating system specific conditionals are enabled based on the OS the code is running on (RuntimeInformation).

KVSerializerOptions accepts has the following options:

  • Conditions - List of conditions to use to match conditional values.
  • HasEscapeSequences - Whether the parser should translate escape sequences (e.g. \n, \t).
  • EnableValveNullByteBugBehavior - Whether invalid escape sequences should truncate strings rather than throwing a InvalidDataException.
  • FileLoader - Provider for referenced files with #include or #base directives.
var options = new KVSerializerOptions
{
    HasEscapeSequences = true,
};
options.Conditions.Clear(); // Remove default conditionals set by the library
options.Conditions.Add("X360WIDE");

var stream = File.OpenRead("file.vdf");

var kv = KVSerializer.Create(KVSerializationFormat.KeyValues1Text);
var data = kv.Deserialize(stream, options);

Deserializing binary

Essentially the same text, just change KeyValues1Text to KeyValues1Binary.

Serializing to text

class DataObject
{
	public string Name { get; set; }

	public string Developer { get; set; }

	[KVProperty("description")]
	public string Summary { get; set; }

	[KVIgnore]
	public string ExtraData { get; set; }
}

var data = new DataObject
{
	Developer = "Valve Software",
	Name = "Dota 2",
	Summary = "Dota 2 is a complex game.",
	ExtraData = "This will not be serialized."
};

using var stream = File.OpenWrite("file.vdf");

var kv = KVSerializer.Create(KVSerializationFormat.KeyValues1Text);
kv.Serialize(stream, data, "root object name");

Serializing to binary

Essentially the same text, just change KeyValues1Text to KeyValues1Binary.

More Repositories

1

ValveResourceFormat

🔬 Valve's Source 2 resource file format parser and decompiler
C#
1,048
star
2

SalienCheat

👽 Cheating Salien minigame, the proper way
PHP
936
star
3

SteamTracking

🕵 Tracking things, so you don't have to
JavaScript
844
star
4

BrowserExtension

💻 SteamDB's extension for Steam websites
JavaScript
710
star
5

GameTracking-Dota2

📥 Game Tracker: Dota 2
Lua
648
star
6

GameTracking-CS2

📥 Game Tracker: Counter-Strike 2
JavaScript
625
star
7

steamdb.info-issues

🚱 Issue tracker for the SteamDB website
412
star
8

Protobufs

👑 Automatically tracked Steam, CS:GO, Dota 2, Artifact, Underlords and TF2 protobufs.
Shell
340
star
9

GameTracking

🛢 Dumping things, so you don't have to
Shell
254
star
10

SteamLinux

🐧 The Big List of Steam Games on GNU/Linux
PHP
207
star
11

FileDetectionRuleSets

🔎 Rules to detect game engines and other technologies based on Steam depot file lists
PHP
177
star
12

UndocumentedAPI

💩 Undocumented Steam WebAPI Methods
91
star
13

ValvePak

📦 Fully fledged library to work with Valve's Pak archives in .NET
C#
90
star
14

MonsterMinigame

☠ Steam Summer Sale 2015 Monster Minigame fully reimplemented server clone
JavaScript
84
star
15

GameTracking-TF2

📥 Game Tracker: Team Fortress 2
Shell
79
star
16

steamstat.us

✅ Front-end of Steam services status website
HTML
74
star
17

SteamAppInfo

Parser for appinfo.vdf and packageinfo.vdf files used by the Steam client
C#
64
star
18

GameTracking-Underlords

📥 Game Tracker: Dota Underlords
CSS
36
star
19

TowerAttack

📊 Historic data of Steam Summer Sale 2015 minigame rooms and their levels
25
star
20

GameTracking-HalfLifeAlyx

📥 Game Tracker: Half-Life: Alyx
CSS
24
star
21

SteamworksDocumentation

📜 Scraper for Steamworks documentation
PHP
24
star
22

GameTracking-SteamVR

📥 Game Tracker: SteamVR Home
JavaScript
23
star
23

SteamTracking-GDPR

📜 Tracking Valve's GDPR related pages
Python
20
star
24

RemoteUI

🏴 Pewpew using unfinished features before they're official released arrrooo
HTML
19
star
25

GameTracking-Dota2Test

📥 Game Tracker: Dota 2 Test
CSS
19
star
26

SteamToTwitter

🕊 Tweets announcements from various Steam groups
C#
16
star
27

RemoteControlDocs

📻 API Documentation for the Steam Remote Control
15
star
28

GameTracking-Artifact-Beta

📥 Game Tracker: Artifact Foundry
Lua
11
star
29

GameTracking-Artifact

📥 Game Tracker: Artifact
CSS
9
star
30

SteamTokenDumper

🔢 Submit users' PICS access tokens to SteamDB
C#
7
star
31

GameTracking-Underlords-Android

📥 Game Tracker: Dota Underlords (Android)
Java
6
star
32

SteamHelpTracking

📜 Tracking Steam Help articles
PHP
2
star
33

.github

💗 Organization-wide community health files
1
star
34

steam-advanced-access-fetch-players

📈 Simple script to fetch Steam player count
JavaScript
1
star