Unfucked.DI
0.0.1-beta.15
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
This is a prerelease version of Unfucked.DI.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Unfucked.DI --version 0.0.1-beta.15
NuGet\Install-Package Unfucked.DI -Version 0.0.1-beta.15
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Unfucked.DI" Version="0.0.1-beta.15" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Unfucked.DI" Version="0.0.1-beta.15" />
<PackageReference Include="Unfucked.DI" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Unfucked.DI --version 0.0.1-beta.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Unfucked.DI, 0.0.1-beta.15"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Unfucked.DI@0.0.1-beta.15
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Unfucked.DI&version=0.0.1-beta.15&prerelease
#tool nuget:?package=Unfucked.DI&version=0.0.1-beta.15&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🧰 Unfucked.DI
Fix egregiously missing or broken functionality in the dependency injection/inversion of control library Microsoft.Extensions.Hosting. Inspired by Spring Framework and JSR-330.
Installation
dotnet package add Unfucked.DI
using Unfucked;
using Unfucked.DI;
Usage
Create an application using ASP.NET Core or a .NET Generic Host:
HostApplicationBuilder appBuilder = new HostApplicationBuilder(args);
using IHost app = appBuilder.Build();
await app.RunAsync();
Dependency Injection
- In addition to searching for configuration JSON files in the current working directory, also search in the executable file's directory, so launching the program with a different CWD doesn't break configuration if that's where you're storing them.
appBuilder.Configuration.AlsoSearchForJsonFilesInExecutableDirectory(); - Allow providers for a dependency service to be injected into a dependent instead of the service itself, which is useful when the dependent either has a longer lifetime than the dependency or needs to make multiple distinct instances of the dependency.
appBuilder.Services .AddInjectableProviders() .AddSingleton<MyDependent>() .AddTransient<MyDependency>(); class MyDependent(Provider<MyDependency> dependencyProvider){ void Run(){ using MyDependency dependency = dependencyProvider.Get(); } } - Change the exit code with which the program exits when a background service crashes, instead of 0 which incorrectly indicates success.
appBuilder.Services.SetExitCodeOnBackgroundServiceException(1); - Easily register a class in the DI context as itself and all of its interfaces and superclasses automatically, so you can inject it as any of the super types without any casting in constructors or unmaintainable multiple registration clutter.
appBuilder.Services .AddSingleton<MyDependency>(alsoRegister: SuperRegistration.INTERFACES | SuperRegistration.SUPERCLASSES); class MyDependency: MyInterface; class MyDependent(MyInterface dependency);- Available for singletons, transients, scoped, hosted, and keyed services.
Logging
- Add a colored console with single-line, column formatted data with simple type names.
appBuilder.Logging.AddUnfuckedConsole(); - Increase the log message level of specified categories/classes and event IDs, in case the author of the original class foolishly logged important messages with at most the same level as lots of unimportant messages, so you can't just decrease your logger level filter for that entire class.
appBuilder.Logging.AmplifyMessageLevels(options => options.Amplify("Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher", LogLevel.Warning, 2, 3, 5, 11, 13, 14, 15, 19, 21, 22, 23, 24)); - Shorter alternatives for logging methods that aren't as ridiculously named as
LogInformation, and that correctly format parameter values according to the current culture so you don't get fucked up percentages like50 %.appBuilder.Logging.AddUnfuckedConsole(); ILogger<MyService> logger; logger.Info("Transfer {progress:P0} done", 0.5); // Transfer 50% done
All Unfucked libraries
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
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 |
|---|---|---|
| 0.0.1-beta.17 | 44 | 5/23/2026 |
| 0.0.1-beta.16 | 148 | 4/16/2026 |
| 0.0.1-beta.15 | 103 | 4/6/2026 |
| 0.0.1-beta.14 | 85 | 3/24/2026 |
| 0.0.1-beta.13 | 75 | 3/19/2026 |
| 0.0.1-beta.12 | 488 | 11/17/2025 |
| 0.0.1-beta.11 | 251 | 11/6/2025 |
| 0.0.1-beta.10 | 191 | 10/21/2025 |
| 0.0.1-beta.9 | 189 | 10/20/2025 |
| 0.0.1-beta.8 | 201 | 10/20/2025 |
| 0.0.1-beta.7 | 178 | 10/19/2025 |
| 0.0.1-beta.6 | 342 | 6/25/2025 |
| 0.0.1-beta.5 | 183 | 6/25/2025 |
| 0.0.1-beta.2 | 175 | 6/23/2025 |
| 0.0.1-beta.1 | 242 | 4/12/2025 |
| 0.0.0-beta6 | 276 | 3/11/2025 |
| 0.0.0-beta5 | 288 | 3/6/2025 |
| 0.0.0-beta4 | 234 | 1/20/2025 |
| 0.0.0-beta3 | 132 | 1/20/2025 |
| 0.0.0-beta2 | 222 | 9/8/2024 |
