Prakrishta.AssemblyScanner 1.0.0

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

Prakrishta.AssemblyScanner

A lightweight, fluent, production‑grade assembly scanning library for .NET. Designed for clean architecture, developer experience, and extensibility.

It supports:

  • Multi‑assembly scanning
  • Open/closed generic interface registration
  • Include/exclude filtering
  • Naming, attribute, base‑class, and namespace conventions
  • Ordered decorator pipelines (non‑generic)
  • Diagnostics logging
  • Registration strategies (Append, Skip, Replace)
  • Summary reporting for debugging and CI visibility

✨ Features

✔ Fluent API

services.Scan(s => s
    .FromAssemblies(assembly1, assembly2)
    .AddClassesAssignableTo(typeof(IHandler<>))
    .AsScoped());

✔ Multi‑assembly scanning

Scan any number of assemblies in a single fluent chain.

✔ Open generic support

services.Scan(s => s
    .FromAssemblyOf<Program>()
    .AddClassesAssignableTo(typeof(IRepository<>))
    .AsScoped());

✔ Include / Exclude filtering

services.Scan(s => s
    .FromAssemblies(assembly)
    .AddClassesAssignableTo(typeof(IService))
    .Include(t => t.Name.EndsWith("Service"))
    .Exclude(t => t.Name.Contains("Legacy")));

✔ Conventions

services.Scan(s => s
    .FromAssemblies(assembly)
    .AddClassesAssignableTo(typeof(IValidator<>))
    .WithNameConvention("Validator")
    .WithAttribute<AutoRegisterAttribute>()
    .WithBaseClass<BaseProcessor>()
    .WithNamespace("MyApp.Services"));

✔ Decorator Pipelines (non‑generic)

services.Scan(s => s
    .FromAssemblies(assembly)
    .AddClassesAssignableTo(typeof(ICommandHandler))
    .Pipeline(p => p
        .Use(typeof(ValidationDecorator))
        .Use(typeof(LoggingDecorator)))
    .AsScoped());

✔ Diagnostics

services.Scan(s => s
    .FromAssemblies(assembly)
    .AddClassesAssignableTo(typeof(IService))
    .WithDiagnostics(Console.WriteLine));

✔ Registration Strategy

services.Scan(s => s
    .FromAssemblies(assembly)
    .AddClassesAssignableTo(typeof(IService))
    .WithStrategy(RegistrationStrategy.Replace));

✔ Summary Reporting

services.Scan(s => s
    .FromAssemblies(assembly)
    .AddClassesAssignableTo(typeof(IService))
    .WithSummary(out var summary));

✔ Build status: Build Status

Package version: NuGet

📦 Installation

Install-Package Prakrishta.AssemblyScanner

🚀 Quick Start

services.Scan(s => s
    .FromAssemblies(typeof(Program).Assembly)
    .AddClassesAssignableTo(typeof(IMyService))
    .AsScoped());

🧠 Decorator Pipelines

Pipelines wrap the resolved service in the order defined:

.Pipeline(p => p
    .Use(typeof(ValidationDecorator))
    .Use(typeof(LoggingDecorator)))

Produces:

ValidationDecorator
    → LoggingDecorator
        → ConcreteService

Important:

Decorators must not be auto‑registered as services.

Use naming conventions (e.g., *Decorator) to exclude them.

🧹 Filtering

Include only types matching a predicate:

.Include(t => t.Name.EndsWith("Handler"))

Exclude types:

.Exclude(t => t.Name.Contains("Legacy"))

Exclude namespace:

.ExcludeNamespace("MyApp.Legacy")

📏 Conventions

Name convention

.WithNameConvention("Service", "Handler")

Attribute convention .WithAttribute<AutoRegisterAttribute>()

Base class convention

.WithBaseClass<BaseProcessor>()

Namespace convention

.WithNamespace("MyApp.Services")

🛡 Validation Rules

The scanner enforces:

  • Decorators must implement the service interface
  • Decorators must have a constructor accepting the service type
  • Pipelines cannot be applied when multiple implementations exist
  • Pipelines cannot be applied to open generics

These rules prevent circular dependencies and invalid registrations.

📊 Summary Reporting

services.Scan(s => s
    .FromAssemblies(assembly)
    .AddClassesAssignableTo(typeof(IService))
    .WithSummary(out var summary));

Console.WriteLine("Registered:");
foreach (var r in summary.Registered)
    Console.WriteLine($" - {r}");

Summary includes:

  • Assemblies scanned
  • Interface types scanned
  • Registered mappings
  • Decorators applied
  • Excluded types

🧪 Testing

The library includes a full MSTest suite covering:

  • Multi‑assembly scanning
  • Open/closed generics
  • Include/exclude filters
  • Conventions
  • Decorator pipelines
  • Registration strategies
  • Diagnostics
  • Summary reporting

📄 License

MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 101 2/1/2026