The C# binding is a single generated file (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/LiveSplit/livesplit-core/llms.txt
Use this file to discover all available pages before exploring further.
LiveSplitCore.cs) that lives in the
LiveSplitCore namespace. It uses P/Invoke (Platform Invocation Services) to call into
the native livesplit_core library without any C++/CLI or interop assemblies.
How the binding is structured
The generator produces three C# classes per livesplit-core type, mirroring the ownership model of the Rust C API:| Class | Rust equivalent | Responsibility |
|---|---|---|
TimerRef | &Timer | Shared borrow — no cleanup |
TimerRefMut | &mut Timer | Mutable borrow — no cleanup |
Timer | OwnedTimer | Owned — must call Dispose() |
Timer, Run, Segment, etc.) implements IDisposable and holds an
IntPtr to the native object. The binding also provides an internal LiveSplitCoreNative
static class that contains all the raw [DllImport] declarations:
LSCoreString class (derived from SafeHandle) handles marshalling UTF-8 strings
between managed and native memory automatically.
Setup
- Copy
LiveSplitCore.csinto your project (any folder). - Copy the native library next to your executable:
livesplit_core.dllon Windowsliblivesplit_core.soon Linuxliblivesplit_core.dylibon macOS
- No NuGet package or additional reference is required — just the two files.
The native library must be resolvable at runtime. Place it in the application directory,
add its folder to
PATH / LD_LIBRARY_PATH, or use NativeLibrary.SetDllImportResolver
to control loading explicitly.Example
using statements for automatic disposal:
Ownership rules
- Every owned object (
Run,Timer,Segment, …) has a finalizer that callsDrop()if you forget to dispose it, but relying on the finalizer delays cleanup indefinitely. - When you pass an owned object to a function (e.g.
Timer.New(run)), the binding zeroes the pointer of the passed object immediately — you must not use it afterwards. RefandRefMutsubclasses are references into another object’s lifetime; never dispose them directly.
Unity
- Build the native library for your target platform(s).
- Copy the platform-specific library to
Assets/Plugins/(or a platform subdirectory such asAssets/Plugins/x86_64/). - Select the library asset in the Unity Editor and configure the Platform settings under the Inspector (OS, CPU architecture).
- Copy
LiveSplitCore.csanywhere insideAssets/. - The
[DllImport("livesplit_core")]attribute matches the asset name automatically on all desktop and Android platforms.