SDL3-CS is the managed C# binding project for SDL3 and the companion SDL_image, SDL_ttf, SDL_mixer, and SDL_shadercross APIs exposed by this repository. It provides the public SDL3 namespace that application and example projects consume.
- P/Invoke declarations and managed convenience wrappers for SDL3 core APIs.
- Add-on bindings for Image, TTF, Mixer, and ShaderCross namespaces.
- C# representations of SDL enums, flags, structs, callbacks, opaque handles, and constants.
- XML documentation generated from upstream SDL documentation and kept warning-clean by repository checks.
- A managed SDL main-callback contract, runtime runner, and opt-in
Mainsource generator. - NuGet package metadata for the managed
SDL3-CSpackage.
The managed wrapper package does not carry platform native binaries. Applications should pair it with exactly one native runtime package family for their target platform, such as SDL3-CS.Windows, SDL3-CS.Linux, SDL3-CS.MacOS, SDL3-CS.Android, SDL3-CS.iOS, or SDL3-CS.tvOS.
| Target | Purpose |
|---|---|
net7.0 |
Long-running applications that still target .NET 7. |
net8.0 |
Current LTS-friendly applications and the test runner baseline. |
net9.0 |
Applications on the .NET 9 line. |
net10.0 |
Latest SDK and example project line in this repository. |
From the repository root:
dotnet build .\SDL3-CS\SDL3-CS.csproj -c ReleaseTo create the managed NuGet package locally:
dotnet pack .\SDL3-CS\SDL3-CS.csproj -c Releasedotnet add package SDL3-CS
dotnet add package SDL3-CS.WindowsReplace Windows with the native package family for the platform that will run the application. Add companion native packages such as SDL3-CS.Windows.Image only when the application uses those companion bindings.
For a callback-based application, implement SDL.IMainCallbacks<TSelf> on a partial class and apply [SDL.GenerateMain]. The analyzer included in SDL3-CS generates Main(string[] args) and calls SDL.RunMainCallbacks<TApp>; direct calls to the runner are also supported.
SDL/contains core SDL3 namespaces grouped by upstream SDL header categories.../SDL3-CS.Generators/contains the opt-in managed main-callback entry-point generator shipped as an analyzer asset.Image/,TTF/,Mixer/, andShaderCross/contain companion library bindings.- Public wrapper methods carry XML documentation; private native entry points stay implementation-focused.
- Unsafe and fixed-buffer shapes are used where SDL ABI compatibility requires them.
Use these checks when changing this project:
dotnet build .\SDL3-CS\SDL3-CS.csproj -c Release
pwsh .\.github\release-tools\Test-PublicWrapperXmlDocs.ps1 -SourceRoot .\SDL3-CSWrapper behavior is covered from the mirrored test project in ../SDL3-CS.Tests.