-
Notifications
You must be signed in to change notification settings - Fork 0
Home
James Burlison edited this page Dec 5, 2025
·
5 revisions
Welcome to the SSDI wiki! SSDI is a lightweight, high-performance dependency injection container designed specifically for .NET games and console applications.
- ⚡ Fast - Expression-compiled factories with near-zero allocation resolution
- 🎮 Game-Friendly - No build step, dynamic registration, hot-swapping support
- 🔧 Simple API - Fluent configuration, intuitive design
- 📦 Lightweight - Minimal footprint, focused feature set
- 🔒 Thread-Safe - Lock-free resolution path, safe for multi-threaded environments.
// Create container
var container = new DependencyInjectionContainer();
// Register services
container.Configure(c =>
{
c.Export<GameEngine>().Lifestyle.Singleton();
c.Export<PlayerService>().As<IPlayerService>();
c.Export<Enemy>(); // Transient by default
});
// Resolve services
var engine = container.Locate<GameEngine>();
var playerService = container.Locate<IPlayerService>();dotnet add package SSDIOr via Package Manager:
Install-Package SSDI| Feature | Description |
|---|---|
| Lifetimes | Singleton, Transient, and Scoped lifetime management |
| Registration | Fluent API for type and interface registration |
| Parameter Injection | Named, positional, and typed constructor parameters |
| Scopes | Per-request/per-player scoped services |
| Unregistration & Events | Hot-swap implementations at runtime |
- Getting Started - Installation and basic usage
- Registration - How to register services
- Lifetimes - Managing service lifetimes
- Parameter Injection - Constructor parameter injection
- Scopes - Working with scoped services
- Unregistration & Events - Dynamic unregistration and event handling
- Advanced Features - Plugin systems, non-public constructors, and more
- Performance - Benchmarks and optimization tips
- API Reference - Complete API documentation
var container = new DependencyInjectionContainer() { EagerCompilation: true }; // EagerCompilation is optional.
container.Configure(c =>
{
// App-lifetime services
c.Export<GameEngine>().Lifestyle.Singleton();
c.Export<NetworkManager>().Lifestyle.Singleton();
// Per-player services
c.Export<PlayerInventory>().As<IInventory>().Lifestyle.Scoped();
c.Export<PlayerStats>().Lifestyle.Scoped();
// Frequently created objects
c.Export<Projectile>();
c.Export<ParticleEffect>();
});
// When a player connects
using var playerScope = container.CreateScope();
var inventory = playerScope.Locate<IInventory>();
var stats = playerScope.Locate<PlayerStats>();
// Player-specific instances, automatically disposed when scope endsSSDI achieves competitive performance with popular DI containers:
| Operation | .NET 8 | .NET 10 |
|---|---|---|
| Singleton Resolution | 5.93 ns | 3.45 ns |
| Transient Resolution | 63.17 ns | 58.42 ns |
| Complex Graph (lazy) | 46.97 ns | 41.28 ns |
| Complex Graph (eager) | 22.47 ns | 19.42 ns |
EagerCompilation mode: Pre-compiles all factories during Configure() for near-parity resolution performance with MS.DI/Grace/DryIoc (~19ns vs ~16ns). Trade-off: slower registration (~10ms vs ~27μs for lazy mode).
See Performance for detailed benchmarks and lazy vs eager comparison.
SSDI is released under the MIT License.
Contributions are welcome! Please visit the GitHub repository to report issues or submit pull requests.