![]() |
VOOZH | about |
dotnet add package FSharp.DI --version 1.0.0
NuGet\Install-Package FSharp.DI -Version 1.0.0
<PackageReference Include="FSharp.DI" Version="1.0.0" />
<PackageVersion Include="FSharp.DI" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="FSharp.DI" />Project file
paket add FSharp.DI --version 1.0.0
#r "nuget: FSharp.DI, 1.0.0"
#:package FSharp.DI@1.0.0
#addin nuget:?package=FSharp.DI&version=1.0.0Install as a Cake Addin
#tool nuget:?package=FSharp.DI&version=1.0.0Install as a Cake Tool
Lightweight functional helpers for Microsoft dependency injection and logging in F#.
dotnet add package FSharp.DI
Program.fsThis is a minimal example of an F# app configuring Microsoft.Extensions.Logging,
initializing FSharp.DI, and then calling a module that has a lazy logger bound with let:
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Logging
open FSharp.DI
open LazyLoggerSample.SampleModule
[<EntryPoint>]
let main _ =
let services =
ServiceCollection()
.AddLogging(fun logging ->
logging.ClearProviders() |> ignore
logging.SetMinimumLevel(LogLevel.Information) |> ignore
logging.AddSimpleConsole(fun options ->
options.TimestampFormat <- "HH:mm:ss "
options.SingleLine <- true
) |> ignore
)
.BuildServiceProvider()
DI.init services
run 42
0
The sample module keeps a lazy logger in a normal module-level let binding:
module LazyLoggerSample.SampleModule
open FSharp.DI
type SampleModuleLog = class end
let private log = DI.loggerLazy<SampleModuleLog>()
let run orderId =
log.Value.info $"Starting work for order {orderId}"
log.Value.warn "Logger created on first use"
The let binding is created when the module loads, but the actual logger is not resolved until
the first log.Value access. That means the pattern is safe as long as DI.init runs before
run is called.
A runnable version of this example is included in samples/LazyLoggerSample/.
This project is licensed under the MIT License — see the file for details.
Faisal Waris — © 2026
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on FSharp.DI:
| Package | Downloads |
|---|---|
|
RTOpenAI.Api
F# library wrapping the OpenAI realtime (voice) API |
|
|
FsAICore
Utility AI functions shared by multiple packages |
|
|
FsPlan
A library for organizing tasks into a plan with either linear or graphical flow |
|
|
RTFlow
A multi-agent AI application framework - capable of handling realtime applications |
|
|
FsPlay
Maui library for programmatically controlling mobile embedded browsers, e.g. via a computer-use-agent |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 281 | 4/20/2026 |