Naravel.Foundation 0.2.0

dotnet add package Naravel.Foundation --version 0.2.0
                    
NuGet\Install-Package Naravel.Foundation -Version 0.2.0
                    
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="Naravel.Foundation" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Naravel.Foundation" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Naravel.Foundation" />
                    
Project file
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 Naravel.Foundation --version 0.2.0
                    
#r "nuget: Naravel.Foundation, 0.2.0"
                    
#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 Naravel.Foundation@0.2.0
                    
#: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=Naravel.Foundation&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Naravel.Foundation&version=0.2.0
                    
Install as a Cake Tool

Naravel.Foundation

NuGet Downloads .NET 10 License: MIT

The shared base of Naravel's driver-based modules: named drivers built once from configuration, replaceable while the application runs, and disposed by one owner.

Fact Detail
Install dotnet add package Naravel.Foundation. Applications get it with the module they use; install it yourself when you write a driver-based module of your own
Targets .NET 10
Needs Microsoft.Extensions.Configuration, Microsoft.Extensions.DependencyInjection.Abstractions, Microsoft.Extensions.Options and Microsoft.Extensions.Options.ConfigurationExtensions, and no other Naravel module
Used by Naravel.Cache, Naravel.Database, Naravel.Filesystem, Naravel.Mail, Naravel.Queue, Naravel.Redis and Naravel.Broadcasting

What you get

  • Named drivers. Manager<TDriver, TOptions> returns the driver registered under a name with Driver(name), or with DriverAsync(name, cancellationToken) when its factory is asynchronous. It builds each driver once, even when callers arrive together, and caches it; a creation that fails is not cached, so the next call tries again.
  • A default and settings from configuration. ManagerOptions carries Default, the name that Driver() uses, and Stores, one configuration section per driver, which a factory reads with GetStore(name). A changed Default applies on the next call; a changed Stores retires the cached drivers, so the next call builds new ones.
  • Drivers added while the application runs. Extend(name, factory) registers a synchronous or asynchronous factory on a manager that is already built and replaces an existing name; Forget(name) and ForgetAll() retire cached instances.
  • Registration. AddNaravelManager registers the manager, its driver registry and a direct TDriver service for the default driver; AddNaravelDriver registers one built-in driver and ConfigureNaravelDrivers several. The overload that takes an IConfiguration binds the options by reflection, so for trimmed or Native AOT applications bind them yourself and call the overload without it.
  • One owner for disposal. The manager disposes the drivers its factories created, except the default driver when it was resolved through the direct TDriver service: dependency injection owns and disposes that one. A driver that fails to dispose does not stop the others; the manager disposes every driver it owns and then throws one AggregateException that holds all the failures.
  • Errors that name the problem. DriverNotRegisteredException carries DriverName, DriverType and AvailableDrivers, and a blank name, a missing default and a missing Stores section each have a fixed message.

Quick start

In a web project (dotnet new web) with this package added, replace Program.cs:

using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Naravel.Foundation;

var builder = WebApplication.CreateBuilder(args);

// 1. Register the manager, its driver registry and the configuration section it reads.
builder.Services.AddNaravelManager<GreeterManager, IGreeter, GreeterOptions>(
    builder.Configuration.GetSection("Greeter"));

// 2. Register a built-in driver under a name.
builder.Services.AddNaravelDriver<IGreeter>("polite", _ => new PoliteGreeter());

var app = builder.Build();
app.MapGet("/hello", (GreeterManager manager) => manager.Driver("polite").Greet("Ada"));
app.Run();

// 3. The contract, the options and the manager. The manager is only a constructor.
public interface IGreeter { string Greet(string name); }

public sealed class GreeterOptions : ManagerOptions { }

public sealed class GreeterManager(IServiceProvider sp, IDriverRegistry<IGreeter> registry, IOptionsMonitor<GreeterOptions> options)
    : Manager<IGreeter, GreeterOptions>(sp, registry, options) { }

public sealed class PoliteGreeter : IGreeter
{
    public string Greet(string name) => $"Hello, {name}!";
}

Run it and open /hello: it answers Hello, Ada!. Set "Greeter": { "Default": "polite" } in appsettings.json and manager.Driver() without a name returns the same driver. Greeter is the example's own module, not a shipped one.

Package Manager built on Foundation Resolves by name
Naravel.Cache CacheManager, LockManager ICacheStore, ICacheLock
Naravel.Database DatabaseManager IDatabaseConnection
Naravel.Filesystem StorageManager IStorageDriver
Naravel.Mail MailManager IMailTransport
Naravel.Queue QueueManager IQueueDriver
Naravel.Redis RedisManager IRedisConnection
Naravel.Broadcasting BroadcastManager IBroadcastDriver

Learn more

Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Naravel.Foundation:

Package Downloads
Naravel.Queue

A Laravel-inspired, driver-based background job queue for .NET. Dispatch, retry with backoff, chaining, batching and a background worker - core package (add Naravel.Queue.Memory for the in-process driver, or Naravel.Queue.Redis/.File/.Database/.RabbitMQ/.Kafka for other backends).

Naravel.Cache

Named cache stores, tagging, scoping and locks for Naravel, built on Naravel.Foundation.

Naravel.Database

Laravel-style query builder for Naravel on ADO.NET and Dapper: named connections on Naravel.Foundation, a connection and transaction seam that EF Core can share, and per-database driver packages.

Naravel.Mail

Typed mail contract for Naravel: Mailable classes, named transports (log, array, SMTP via an optional package) and a test fake, built on Naravel.Foundation.

Naravel.Redis

Named, shared Redis connections for Naravel modules: one StackExchange.Redis multiplexer per name, owned and disposed by one manager.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 577 11/13/2026
0.1.1 384 11/2/2026
0.1.0 393 11/1/2026