Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

demofile-net

> 编程语言
Open source

Blazing fast cross-platform demo parser library for Counter-Strike 2 and Valve's Deadlock, written in C#.

182 stars0 likes1 views
WebsiteGitHub

About

Blazing fast cross-platform demo parser library for Counter-Strike 2 and Valve's Deadlock, written in C#.

DemoFile.Net

DemoFile.Net is a blazing fast demo parser library for Source 2 games, written in C#. It is cross-platform, and can be used on Windows, Mac or Linux. This parser currently supports:

Game NuGet package Getting started
Counter-Strike 2 ✅ DemoFile.Game.Cs new CsDemoParser()
Deadlock ✅ DemoFile.Game.Deadlock new DeadlockDemoParser()

[!IMPORTANT] DemoFile is the base, core library and does not provide support for parsing any specific game. Add a reference to one of the DemoFile.Game.* packages instead.

Easy discoverability of available data through your IDE's inbuilt autocompletion:

Features

Feature Availability
CSTV / GOTV demos ✅ Full support
POV demos ✅ Full support
HTTP broadcasts ✅ Full support
Game events (e.g. player_death) ✅ Full support
Entity updates (player positions, grenades, etc.) ✅ Full support
Seeking forwards/backwards through the demo ✅ Full support

Getting Started

Installation

Add the appropriate NuGet package to your project:

bash
# For Counter-Strike 2
dotnet add package DemoFile.Game.Cs

# For Deadlock
dotnet add package DemoFile.Game.Deadlock

Basic Usage

Here's a simple example that prints kill feed information from a CS2 demo:

csharp
using DemoFile;

internal class Program
{
    public static async Task Main(string[] args)
    {
        var path = args.SingleOrDefault() ?? throw new Exception("Expected a single argument: ");

        var demo = new CsDemoParser();
        demo.Source1GameEvents.PlayerDeath += e =>
        {
            Console.WriteLine($"{e.Attacker?.PlayerName} [{e.Weapon}] {e.Player?.PlayerName}");
        };

        var reader = DemoFileReader.Create(demo, File.OpenRead(path));
        await reader.ReadAllAsync();

        Console.WriteLine("\nFinished!");
    }
}

Advanced Examples

Tracking Player Positions

You can track player positions and other entity data throughout the demo:

csharp
var demo = new CsDemoParser();

// Subscribe to tick events to get data at specific points in time
demo.TickEnd += (_, tick) =>
{
    // Get all active players
    foreach (var player in demo.Entities.Players)
    {
        if (player.Pawn is { } pawn)
        {
            Console.WriteLine($"Player {player.PlayerName} is at position {pawn.CBodyComponent?.Position}");
        }
    }
};

var reader = DemoFileReader.Create(demo, File.OpenRead(demoPath));
await reader.ReadAllAsync();

Working with Game Events

DemoFile.Net provides strongly-typed access to game events:

csharp
var demo = new CsDemoParser();

// Track round wins
demo.Source1GameEvents.RoundEnd += e => 
{
    Console.WriteLine($"Round ended. Winner: {e.Winner}. Reason: {e.Reason}");
};

// Track bomb events
demo.Source1GameEvents.BombPlanted += e => 
{
    Console.WriteLine($"Bomb planted by {e.Player?.PlayerName} at site {e.Site}");
};

demo.Source1GameEvents.BombDefused += e => 
{
    Console.WriteLine($"Bomb defused by {e.Player?.PlayerName}");
};

var reader = DemoFileReader.Create(demo, File.OpenRead(demoPath));
await reader.ReadAllAsync();

Parallel Processing for Maximum Performance

For maximum performance, parse demos in parallel using multiple CPU cores:

csharp
var demo = new CsDemoParser();
// Set up your event handlers...

var reader = DemoFileReader.Create(demo, File.OpenRead(demoPath));
await reader.ReadAllParallelAsync();  // Uses all available CPU cores

HTTP Broadcast Support

DemoFile.Net can parse live HTTP broadcasts:

csharp
var demo = new CsDemoParser();
// Set up your event handlers...

var reader = HttpBroadcastReader.Create(demo, "http://localhost:8080/broadcast");
await reader.ReadAllAsync();

See the examples/ folder for more complete examples:

  • Basic - Simple demo parsing
  • MultiThreaded - Parallel processing for maximum performance
  • PlayerPositions - Tracking player positions and movements
  • HttpBroadcast - Parsing live HTTP broadcasts

Benchmarks

DemoFile.Net can read a full competitive game (just under 1 hour of game time) in under a second. When parsing across multiple threads, using the ReadAllParallelAsync method, this drops to 353 milliseconds. This includes parsing all entity data (player positions, velocities, weapon tracking, grenades, etc).

Apple M1 Pro, 1 CPU, 10 logical and 10 physical cores .NET 10.0.0 (10.0.25.52411), Arm64 RyuJIT AdvSIMD

Method Mean Gen0 Gen1 Gen2 Allocated
ParseDemo 903.0 ms 88000.0000 1000.0000 - 597.58 MB
ParseDemoParallel 353.2 ms 104000.0000 15000.0000 1000.0000 690.59 MB

Author and acknowledgements

DemoFile.Net is developed by Saul Rennison. The development of this library would not have been possible without demoparser by LaihoE and Manta by Dotabuff, the latter of which depends on the efforts of a number of people:

  • Michael Fellinger built Dotabuff's Source 1 parser yasha.
  • Robin Dietrich built the C++ parser Alice.
  • Martin Schrodt built the Java parser clarity.
  • Drew Schleck built an original C++ parser edith.

A modified version of Source2Gen by neverlosecc is used to statically generate the game schema classes and enums.

See ACKNOWLEDGEMENTS for license information.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言