Modrich.Modularity
0.1.0
dotnet add package Modrich.Modularity --version 0.1.0
NuGet\Install-Package Modrich.Modularity -Version 0.1.0
<PackageReference Include="Modrich.Modularity" Version="0.1.0" />
<PackageVersion Include="Modrich.Modularity" Version="0.1.0" />
<PackageReference Include="Modrich.Modularity" />
paket add Modrich.Modularity --version 0.1.0
#r "nuget: Modrich.Modularity, 0.1.0"
#:package Modrich.Modularity@0.1.0
#addin nuget:?package=Modrich.Modularity&version=0.1.0
#tool nuget:?package=Modrich.Modularity&version=0.1.0
Modrich.Modularity
Module discovery and DI registration engine for the Modrich modular foundation for .NET 10. This is the package the host references — modules themselves should depend on Modrich.Abstractions (or one of the SDK meta-packages).
What's in the box
ModuleAssemblyLocator.Discover()— scansDependencyContext.Defaultand returns every assembly carrying[assembly: ModuleAssembly]. Uses the deps file (notGetReferencedAssemblies) so project references still surface even when the compiler strips unused metadata refs.ModuleAssemblyCatalog— read-only list of discovered assemblies (useful for MVC:AddApplicationPart(...), EF:ApplyConfigurationsFromAssembly(...)).ModuleExtensions—IServiceCollection/WebApplication/IEndpointRouteBuilderextensions:RegisterApiModules(configuration, onRegistered?)RegisterAppModules(configuration, apiBaseUrl?, onRegistered?)RegisterModules(configuration, apiBaseUrl?, onApiRegistered?, onAppRegistered?)— unified host (API + UI in one process)ConfigureModulePipelines(app)— invokesIAppModule.ConfigureAppPipelineMapModuleEndpoints(endpoints)— invokesIAppModule.MapAppEndpointsGetModuleAssemblies<TModule>()— assemblies that contain a concrete implementation ofTModuleReadModuleConfig(configuration)— strongly-typed view of theModules:*config section
ModuleRegistry—IModuleRegistryimplementation.
Install
dotnet add package Modrich.Modularity
Usage — API-only host
using Modrich.Modules;
var builder = WebApplication.CreateBuilder(args);
builder.Services.RegisterApiModules(builder.Configuration);
var app = builder.Build();
app.MapControllers();
app.Run();
RegisterApiModules:
- Discovers every
[assembly: ModuleAssembly]assembly and instantiates eachIApiModule. - Calls
RegisterApiDependencies(services, configuration)on each. - Aggregates
IModule.Permissions+ implicitModule.{Name}.Accessinto aPermissionCatalog. - Registers
PermissionAuthorizationPolicyProviderso[Authorize(Policy = "...")]resolves dynamically. - Registers an
IModuleRegistrysnapshot.
Usage — App (UI) host
builder.Services.RegisterAppModules(builder.Configuration, apiBaseUrl: "https://api.acme.com");
var app = builder.Build();
app.ConfigureModulePipelines(); // before UseAuthentication
app.UseAuthentication();
app.UseAuthorization();
app.MapModuleEndpoints();
app.Run();
Usage — unified host (API + UI in one process)
builder.Services.RegisterModules(builder.Configuration, apiBaseUrl: "https://localhost");
A module whose Modules:<Name>:ApiBaseUrl is set in configuration is treated as externally hosted: only its UI-side dependencies are wired (Refit clients targeting the external URL); its API-side DI is skipped. Permissions are still aggregated either way.
appsettings.json:
{
"Modules": {
"Orders": { "ApiBaseUrl": "https://orders.acme.com" },
"Products": { }
}
}
Usage — MVC controllers and EF configs from modules
var catalog = new ModuleAssemblyCatalog { Assemblies = ModuleAssemblyLocator.Discover() };
var mvc = builder.Services.AddControllers();
foreach (var asm in catalog.Assemblies)
mvc.AddApplicationPart(asm);
builder.Services.AddDbContext<AppDbContext>((sp, opt) =>
opt.UseSqlServer(connectionString,
b => b.MigrationsAssembly(typeof(AppDbContext).Assembly.GetName().Name)));
Inside an EF OnModelCreating:
foreach (var asm in moduleAssemblyCatalog.Assemblies)
modelBuilder.ApplyConfigurationsFromAssembly(asm);
Related packages
Modrich.Abstractions— module contracts.Gatekeep.Authorization/Gatekeep.Authorization.Abstractions— the catalog + policy provider this package registers.Modrich.Navigation.Abstractions— picked up by App modules.Modrich.Persistence— pair with this to run module migrations + seeders.
License
MIT.
| 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
- Gatekeep.Authorization (>= 0.0.1)
- Microsoft.Extensions.DependencyModel (>= 10.0.8)
- Modrich.Abstractions (>= 0.1.0)
- Modrich.Navigation.Abstractions (>= 0.1.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Modrich.Modularity:
| Package | Downloads |
|---|---|
|
Modrich.Sdk.Web
Package Description |
|
|
Modrich.Persistence
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.