X39.Hosting.Modularization.TemplatePackage 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet new install X39.Hosting.Modularization.TemplatePackage::0.0.1
This package contains a .NET Template Package you can call from the shell/command line.

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 the ModuleContext. 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
  • net6.0

    • No dependencies.

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.27 451 9/21/2023
0.0.1.26 342 5/4/2023
0.0.1.24 620 10/16/2022
0.0.1.23 326 10/16/2022
0.0.1.22 325 10/16/2022
0.0.1.21 323 10/15/2022
0.0.1.20 336 10/15/2022
0.0.1.19 335 10/15/2022
0.0.1.18 368 10/1/2022
0.0.1.17 323 10/1/2022
0.0.1.16 319 10/1/2022
0.0.1.15 380 9/24/2022
0.0.1.14 390 9/21/2022
0.0.1.13 335 9/20/2022
0.0.1.12 328 9/20/2022
0.0.1.11 353 9/15/2022
0.0.1.10 396 9/14/2022
0.0.1.9 404 9/6/2022
0.0.1.8 363 9/5/2022
0.0.1.7 366 9/2/2022
0.0.1 391 9/1/2022