Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection in .NET applications.
Scrutor is a .NET library that extends Microsoft.Extensions.DependencyInjection with assembly scanning and service decoration capabilities. It solves the problem of manually registering numerous services in dependency injection containers by automatically discovering types from assemblies, and enables clean implementation of the decorator pattern for cross-cutting concerns.
.NET developers using Microsoft's dependency injection container who need to reduce boilerplate service registration code or implement decorator patterns for cross-cutting concerns like logging, caching, or validation.
Developers choose Scrutor because it provides missing but essential functionality for the standard Microsoft DI container with a clean, intuitive API that follows existing .NET patterns, eliminating the need for manual service registration or complex workarounds for decoration.
Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically discovers and registers types from assemblies using configurable filters, drastically reducing boilerplate code for DI setup, as shown in the scanning examples.
Provides a straightforward API to decorate services for cross-cutting concerns like logging or caching, enabling the decorator pattern without modifying original implementations.
Supports filtering by base types, interfaces, namespaces, attributes, and even compiler-generated types for UI frameworks like Avalonia, as detailed in the README.
Capable of scanning and registering open generic interfaces and types with multiple parameters, simplifying DI for generic patterns.
The README warns that compiler-generated types (e.g., from UI frameworks) can implement many interfaces, leading to unintended registrations if filters are not precise, requiring careful configuration.
Scrutor only extends Microsoft.Extensions.DependencyInjection, creating vendor lock-in and making it unsuitable for projects using alternative containers with more features.
Assembly scanning can introduce startup performance issues in large applications, as it reflects over all types, which might not be optimal for high-performance or minimal overhead scenarios.