• Stars
    star
    104
  • Rank 328,473 (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