Ouse.Godot.DependencyInjection
1.0.0
dotnet add package Ouse.Godot.DependencyInjection --version 1.0.0
NuGet\Install-Package Ouse.Godot.DependencyInjection -Version 1.0.0
<PackageReference Include="Ouse.Godot.DependencyInjection" Version="1.0.0" />
<PackageVersion Include="Ouse.Godot.DependencyInjection" Version="1.0.0" />
<PackageReference Include="Ouse.Godot.DependencyInjection" />
paket add Ouse.Godot.DependencyInjection --version 1.0.0
#r "nuget: Ouse.Godot.DependencyInjection, 1.0.0"
#:package Ouse.Godot.DependencyInjection@1.0.0
#addin nuget:?package=Ouse.Godot.DependencyInjection&version=1.0.0
#tool nuget:?package=Ouse.Godot.DependencyInjection&version=1.0.0
Ouse.Godot.DependencyInjection
Scene-tree cascading DI for Godot 4 (.NET), built on Microsoft.Extensions.DependencyInjection.
API style mirrors Chickensoft.AutoInject (attributes + _Notification), but the container is MSDI with cascading IServiceProvider scopes.
dotnet add package Ouse.Godot.DependencyInjection --version 1.0.0
Full docs: build with DocFX (docfx docfx.json) or read docs/v1.0/ in the repo.
When referencing the project directly (not NuGet), also add the generator and analyzer:
<ProjectReference Include="...\Ouse.Godot.DependencyInjection.csproj" />
<ProjectReference Include="...\Ouse.Godot.DependencyInjection.Generators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
<ProjectReference Include="...\Ouse.Godot.DependencyInjection.Analyzers.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
Usage
Every participating node must forward notifications (same requirement as AutoInject):
public override void _Notification(int what) => this.NotifyDi(what);
The analyzer OGD020 errors if this line is missing; Visual Studio / Rider can apply the code fix “Add _Notification ⇒ NotifyDi(what)”.
Service host (Provider)
[ServiceHost(InheritParent = false)] // Autoload root
public partial class GameServices : Node
{
public override void _Notification(int what) => this.NotifyDi(what);
private void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IAudio, GodotAudioService>();
}
}
Inject (Dependent)
public partial class Spawner : Node
{
public override void _Notification(int what) => this.NotifyDi(what);
[Inject] public ILevelConfig Config { get; private set; } = null!;
[Inject] public IAudio Audio { get; private set; } = null!;
private void OnInjected()
{
Audio.Play("spawn");
}
}
AutoNode (scene child binding)
Chickensoft AutoConnect / [Node] analogue — bind properties to child nodes by name or path (Ready, before [Inject]):
[AutoNode] // child named "Spawner", or unique name %Spawner
public Spawner Spawner { get; private set; } = null!;
[AutoNode("Player")] // explicit path
public Player Player { get; private set; } = null!;
[AutoNode("Player/Weapon")]
public Weapon Weapon { get; private set; } = null!;
| Chickensoft | This library |
|---|---|
Provider + Provide() |
[ServiceHost] + ConfigureServices |
[Dependency] + DependOn<T>() |
[Inject] properties |
[Node] / AutoConnect |
[AutoNode] |
Notify / OnResolved |
NotifyDi / OnInjected |
No Node subclasses are shipped in the package DLL — stubs are source-generated into your game assembly (required for Godot C# hot-reload).
Hot reload: after changing ConfigureServices registrations, restart the editor/game so hosts rebuild.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- GodotSharp (>= 4.7.1)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 144 | 8/14/2026 |
Initial 1.0.0 release: [ServiceHost], [Inject], [AutoNode], NotifyDi, cascading MSDI scopes, OGD020 analyzer + code fix.