8000 SDL3-CS/SDL3-CS at main · edwardgushchin/SDL3-CS · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History

SDL3-CS

Folders and files

README.md

SDL3-CS Managed Wrapper Project

.NET 7, 8, 9, and 10 C# 14 SDL target 3.4.20 NuGet package SDL3-CS

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.

What This Project Contains

  • 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 Main source generator.
  • NuGet package metadata for the managed SDL3-CS package.

What This Project Does Not Ship

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 Frameworks

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.

Build

From the repository root:

dotnet build .\SDL3-CS\SDL3-CS.csproj -c Release

To create the managed NuGet package locally:

dotnet pack .\SDL3-CS\SDL3-CS.csproj -c Release

Consumer Usage

dotnet add package SDL3-CS
dotnet add package SDL3-CS.Windows

Replace 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.

Source Layout

  • 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/, and ShaderCross/ 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.

Verification

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-CS

Wrapper behavior is covered from the mirrored test project in ../SDL3-CS.Tests.

Related Documentation

0