Netloji.PluginService.Hosting 1.0.0-preview.2

This is a prerelease version of Netloji.PluginService.Hosting.
dotnet add package Netloji.PluginService.Hosting --version 1.0.0-preview.2
                    
NuGet\Install-Package Netloji.PluginService.Hosting -Version 1.0.0-preview.2
                    
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="Netloji.PluginService.Hosting" Version="1.0.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Netloji.PluginService.Hosting" Version="1.0.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="Netloji.PluginService.Hosting" />
                    
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 Netloji.PluginService.Hosting --version 1.0.0-preview.2
                    
#r "nuget: Netloji.PluginService.Hosting, 1.0.0-preview.2"
                    
#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 Netloji.PluginService.Hosting@1.0.0-preview.2
                    
#: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=Netloji.PluginService.Hosting&version=1.0.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Netloji.PluginService.Hosting&version=1.0.0-preview.2&prerelease
                    
Install as a Cake Tool

Netloji.PluginService

A .NET plugin system with isolated AssemblyLoadContext, hot-reload, and first-class DI integration. Bir .NET eklenti sistemi — izole AssemblyLoadContext, sıcak yükleme ve birinci sınıf DI desteği.


🇬🇧 English

Overview

Netloji.PluginService is a modular, production-ready plugin framework for .NET 10+ (with netstandard2.1 support for abstractions). It provides:

  • Isolated loading — each plugin runs in its own AssemblyLoadContext with dependency resolution
  • Hot-reload — watch plugin directories and load/unload without restarting the host
  • DI-first — plugins integrate with IServiceProvider, ILogger, IConfiguration, HttpClient
  • Event bus — built-in publish/subscribe for inter-plugin communication
  • REST API — optional ASP.NET Core hosting with management endpoints
  • Integrity checks — SHA-256 hashing for plugin assemblies
  • Packaging — .netpkg binary format for distribution
  • Collectible contexts — unload plugins fully when no longer needed (.NET 10+)

Packages

Package NuGet Description
Netloji.PluginService.Abstractions NuGet Interfaces (IPlugin, IPluginContext), attributes (PluginAttribute), base classes (PluginBase) and models
Netloji.PluginService NuGet Runtime: PluginManager, PluginRegistry, PluginLoadContext, watcher, packaging, hasher
Netloji.PluginService.Hosting NuGet ASP.NET Core hosting: PluginHostedService, REST API endpoints, DI extensions

Quick Start

1. Install
dotnet add package Netloji.PluginService
dotnet add package Netloji.PluginService.Hosting   # optional, for ASP.NET Core
2. Register in your host
// Program.cs
builder.Services.AddNetlojiPlugins(builder.Configuration, opts =>
{
    opts.PluginDirectory = "Plugins";
    opts.PluginFilePattern = "MyCompany.Plugins.*.dll";
    opts.WatchForChanges = true;          // hot-reload enabled
    opts.EnableUnload = true;             // collectible ALC
    opts.HttpClientTimeout = TimeSpan.FromSeconds(60);
});

// Optional: map the REST API
app.MapNetlojiPluginApi("/api/plugins");
3. Create a plugin

Create a new class library project:

dotnet new classlib -o MyCompany.Plugins.Greeter
using Netloji.PluginService.Abstractions;
using Microsoft.Extensions.Logging;

[Plugin("mycompany.greeter", "1.0.0", "Greeter Plugin",
    Description = "A friendly greeting plugin",
    Author = "You",
    Tags = new[] { "example", "greeter" },
    Capabilities = new[] { PluginCapability.Source })]
public class GreeterPlugin : PluginBase
{
    public override PluginMetadata Metadata { get; }

    public override async Task OnLoadedAsync(IPluginContext ctx, CancellationToken ct)
    {
        ctx.Log(LogLevel.Information, "GreeterPlugin loaded!");

        var client = ctx.Http;
        var config = ctx.GetSection("Greeter");
        var greeting = config["Message"] ?? "Hello from plugin!";

        ctx.Log(LogLevel.Information, greeting);
    }

    public override Task OnUnloadedAsync(CancellationToken ct)
    {
        Context?.Log(LogLevel.Information, "Goodbye from plugin!");
        return Task.CompletedTask;
    }
}
4. Build and run
dotnet build -c Release
# Copy the plugin DLL to your host's Plugins/ directory
# The host loads it automatically on startup (or via hot-reload)

Plugin Lifecycle

Discovery → LoadAssembly → Create PluginLoadContext
    → Scan for [Plugin] types → Instantiate via DI
    → Call OnLoadedAsync(context) → Register in PluginRegistry
    → [Runtime] → Call OnUnloadedAsync() → Unload ALC

REST API (Hosting package)

Method Endpoint Description
GET /api/plugins/ List all plugins
GET /api/plugins/{id} Get plugin detail
DELETE /api/plugins/{id} Unload a plugin
POST /api/plugins/{id}/reload Reload a plugin
GET /api/plugins/capabilities/{cap} Filter by capability

Project Structure

Netloji.PluginService/
├── src/
│   ├── Netloji.PluginService.Abstractions/   # Contracts & models
│   ├── Netloji.PluginService/                 # Runtime engine
│   └── Netloji.PluginService.Hosting/         # ASP.NET Core hosting
├── tests/
│   ├── Abstractions.Tests/
│   ├── Tests/
│   └── IntegrationTests/
├── samples/
│   ├── Hello.Plugin/
│   ├── DataSource.Plugin/
│   └── Composite.Host/
└── docs/

Requirements

  • .NET 10 SDK or later
  • ASP.NET Core 10.0+ (for Hosting package)

🇹🇷 Türkçe

Genel Bakış

Netloji.PluginService, .NET 10+ için geliştirilmiş, üretime hazır bir eklenti (plugin) altyapısıdır. Temel özellikler:

  • İzole yükleme — her eklenti kendi AssemblyLoadContext'inde bağımlılıklarıyla birlikte çalışır
  • Sıcak yükleme — uygulamayı durdurmadan eklenti yükleme/kaldırma, dosya değişikliklerini izleme
  • DI desteği — IServiceProvider, ILogger, IConfiguration, HttpClient ile tam uyum
  • Olay iletisi — eklentiler arası publish/subscribe mekanizması
  • REST API — ASP.NET Core ile isteğe bağlı yönetim endpoint'leri
  • Bütünlük denetimi — SHA-256 ile eklenti bütünlük sağlama
  • Paketleme — .netpkg binary formatı ile dağıtım
  • Toplanabilir context — eklentiler tamamen bellekten atılabilir (.NET 10+)

Paketler

Paket NuGet Açıklama
Netloji.PluginService.Abstractions NuGet Arayüzler (IPlugin, IPluginContext), nitelikler (PluginAttribute), temel sınıflar (PluginBase) ve modeller
Netloji.PluginService NuGet Çalışma zamanı: PluginManager, PluginRegistry, PluginLoadContext, dosya izleyici, paketleme
Netloji.PluginService.Hosting NuGet ASP.NET Core hosting: PluginHostedService, REST API endpoint'leri, DI eklentileri

Hızlı Başlangıç

1. Paketleri ekleyin
dotnet add package Netloji.PluginService
dotnet add package Netloji.PluginService.Hosting   # ASP.NET Core için isteğe bağlı
2. Host'a kaydedin
// Program.cs
builder.Services.AddNetlojiPlugins(builder.Configuration, opts =>
{
    opts.PluginDirectory = "Plugins";
    opts.PluginFilePattern = "MyCompany.Plugins.*.dll";
    opts.WatchForChanges = true;
    opts.EnableUnload = true;
    opts.HttpClientTimeout = TimeSpan.FromSeconds(60);
});

// REST API'yi aktif edin
app.MapNetlojiPluginApi("/api/plugins");
3. Bir eklenti yazın
[Plugin("mycompany.greeter", "1.0.0", "Greeter Plugin",
    Description = "Örnek bir eklenti",
    Author = "Adınız",
    Tags = new[] { "ornek", "greeter" },
    Capabilities = new[] { PluginCapability.Source })]
public class GreeterPlugin : PluginBase
{
    public override PluginMetadata Metadata { get; }

    public override async Task OnLoadedAsync(IPluginContext ctx, CancellationToken ct)
    {
        ctx.Log(LogLevel.Information, "GreeterPlugin yüklendi!");
        var greeting = ctx.GetSection("Greeter")["Message"] ?? "Merhaba!";
        ctx.Log(LogLevel.Information, greeting);
    }

    public override Task OnUnloadedAsync(CancellationToken ct)
    {
        Context?.Log(LogLevel.Information, "Eklenti kaldırılıyor...");
        return Task.CompletedTask;
    }
}
4. Derleyin ve çalıştırın
dotnet build -c Release
# Çıkan DLL'i host uygulamasının Plugins/ klasörüne kopyalayın
# Host, eklentiyi başlangıçta veya sıcak yükleme ile otomatik alır

Eklenti Yaşam Döngüsü

Keşif → Assembly Yükle → PluginLoadContext oluştur
    → [Plugin] tiplerini tara → DI ile örnekle
    → OnLoadedAsync(context) çağır → PluginRegistry'e kaydet
    → [Çalışma Zamanı] → OnUnloadedAsync() çağır → ALC'yi kaldır

REST API (Hosting paketi)

Method Endpoint Açıklama
GET /api/plugins/ Tüm eklentileri listele
GET /api/plugins/{id} Eklenti detayını göster
DELETE /api/plugins/{id} Eklentiyi kaldır
POST /api/plugins/{id}/reload Eklentiyi yeniden yükle
GET /api/plugins/capabilities/{cap} Yeteneğe göre filtrele

Gereksinimler

  • .NET 10 SDK veya üzeri
  • ASP.NET Core 10.0+ (Hosting paketi için)

License / Lisans

This project is licensed under the MIT License. See LICENSE for details. Bu proje MIT lisansı ile lisanslanmıştır. Detaylar için LICENSE dosyasına bakın.

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

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
1.0.0-preview.2 79 6/7/2026
1.0.0-preview.1 61 6/7/2026