X39.Hosting.Modularization
0.0.1
See the version list below for details.
dotnet add package X39.Hosting.Modularization --version 0.0.1
NuGet\Install-Package X39.Hosting.Modularization -Version 0.0.1
<PackageReference Include="X39.Hosting.Modularization" Version="0.0.1" />
paket add X39.Hosting.Modularization --version 0.0.1
#r "nuget: X39.Hosting.Modularization, 0.0.1"
// Install X39.Hosting.Modularization as a Cake Addin #addin nuget:?package=X39.Hosting.Modularization&version=0.0.1 // Install X39.Hosting.Modularization as a Cake Tool #tool nuget:?package=X39.Hosting.Modularization&version=0.0.1
Quickstart
A simple setup looks as follows:
// Program.cs
var hostBuilder = Host.CreateDefaultBuilder(args);
hostBuilder.UseModularization(Path.GetFullPath("Modules"));
hostBuilder.ConfigureServices(collection => collection.AddHostedService<Worker>());
var host = hostBuilder.Build();
host.Run();
// Worker.cs
public class Worker : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await _moduleLoader.LoadAllAsync(stoppingToken);
}
}
Please do note that plugin directories are provided once at start.
Features
module.json
configuration file to provide information about the module:The module configuration allows to declare things like a guid for the module to uniquely identify them over successive runs, offers a way to declare a module license, list the licenses used in the module and much more.
Automatic dependency resolution:
A module can depend on another module by providing a dependency in the
module.json
file.Module unloading:
Unloading a module is as simple as calling
Unload()
on theModuleContext
. Please do note that normal unloading rules apply - as in: even having a type reference is enough to prevent proper unloading of the assembly. To debug theese, checking which objects are still loaded (Rider → Memory Tab; Visual Studio → Take .net object snapshot with diagnostics tool; for both check the types that live in the loaded module) can be a useful tool in your tookit. A common issue eg. is caching that prevents the types from being properly released by the garbage collector.Clear entry point:
Every module must, for it to properly function, implement the
IModuleMain
interface. This allows the module to work more or less like the normal ´void Main()` you know and love.Dependency Injection for modules:
Every main module class is constructed by dependency injection, using
IServiceProvider
. It even supports nullable references so you do not have to ever worry about invalid "not null" references ever again.
ToDo's
- Add version checks to dependency resolution
- Document and style all exceptions properly
- Offer a way to "include" types to prevent type duplicates
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net6.0
- JetBrains.Annotations (>= 2022.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.1)
- X39.Hosting.Modularization.Abstraction (>= 0.0.1)
- X39.Util (>= 1.0.0.33)
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 |
---|---|---|
2.0.0.34 | 106 | 9/28/2024 |
1.0.0.33 | 106 | 9/16/2024 |
1.0.0.32-da89c1738d81a83aaf... | 66 | 9/16/2024 |
1.0.0.30-d7feb86db9bc881b33... | 68 | 9/16/2024 |
1.0.0.29-d9f5be5a6cc6bd85d6... | 68 | 9/16/2024 |
0.0.1.27 | 188 | 9/21/2023 |
0.0.1.26 | 165 | 5/4/2023 |
0.0.1.24 | 403 | 10/16/2022 |
0.0.1.23 | 356 | 10/16/2022 |
0.0.1.22 | 366 | 10/16/2022 |
0.0.1.21 | 374 | 10/15/2022 |
0.0.1.20 | 376 | 10/15/2022 |
0.0.1.19 | 387 | 10/15/2022 |
0.0.1.18 | 384 | 10/1/2022 |
0.0.1.17 | 360 | 10/1/2022 |
0.0.1.16 | 361 | 10/1/2022 |
0.0.1.15 | 385 | 9/24/2022 |
0.0.1.14 | 384 | 9/21/2022 |
0.0.1.13 | 368 | 9/20/2022 |
0.0.1.12 | 397 | 9/20/2022 |
0.0.1.11 | 388 | 9/15/2022 |
0.0.1.10 | 411 | 9/14/2022 |
0.0.1.9 | 411 | 9/6/2022 |
0.0.1.8 | 385 | 9/5/2022 |
0.0.1.7 | 404 | 9/2/2022 |
0.0.1.6 | 385 | 9/1/2022 |
0.0.1 | 406 | 9/1/2022 |