![]() |
VOOZH | about |
dotnet add package Scrutor --version 7.0.0
NuGet\Install-Package Scrutor -Version 7.0.0
<PackageReference Include="Scrutor" Version="7.0.0" />
<PackageVersion Include="Scrutor" Version="7.0.0" />Directory.Packages.props
<PackageReference Include="Scrutor" />Project file
paket add Scrutor --version 7.0.0
#r "nuget: Scrutor, 7.0.0"
#:package Scrutor@7.0.0
#addin nuget:?package=Scrutor&version=7.0.0Install as a Cake Addin
#tool nuget:?package=Scrutor&version=7.0.0Install as a Cake Tool
Scrutor - I search or examine thoroughly; I probe, investigate or scrutinize
From scrūta, as the original sense of the verb was to search through trash. - https://en.wiktionary.org/wiki/scrutor
Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection
Install the Scrutor NuGet Package.
Install-Package Scrutor
dotnet add package Scrutor
The library adds two extension methods to IServiceCollection:
Scan - This is the entry point to set up your assembly scanning.Decorate - This method is used to decorate already registered services.See Examples below for usage examples.
var collection = new ServiceCollection();
collection.Scan(scan => scan
// We start out with all types in the assembly of ITransientService
.FromAssemblyOf<ITransientService>()
// AddClasses starts out with all public, non-abstract types in this assembly.
// These types are then filtered by the delegate passed to the method.
// In this case, we filter out only the classes that are assignable to ITransientService.
.AddClasses(classes => classes.AssignableTo<ITransientService>())
// We then specify what type we want to register these classes as.
// In this case, we want to register the types as all of its implemented interfaces.
// So if a type implements 3 interfaces; A, B, C, we'd end up with three separate registrations.
.AsImplementedInterfaces()
// And lastly, we specify the lifetime of these registrations.
.WithTransientLifetime()
// Here we start again, with a new full set of classes from the assembly above.
// This time, filtering out only the classes assignable to IScopedService.
.AddClasses(classes => classes.AssignableTo<IScopedService>())
// Now, we just want to register these types as a single interface, IScopedService.
.As<IScopedService>()
// And again, just specify the lifetime.
.WithScopedLifetime()
// Generic interfaces are also supported too, e.g. public interface IOpenGeneric<T>
.AddClasses(classes => classes.AssignableTo(typeof(IOpenGeneric<>)))
.AsImplementedInterfaces()
// And you scan generics with multiple type parameters too
// e.g. public interface IQueryHandler<TQuery, TResult>
.AddClasses(classes => classes.AssignableTo(typeof(IQueryHandler<,>)))
.AsImplementedInterfaces());
By default, Scrutor excludes compiler-generated types from the .AddClasses() type filters. When loading views from a framework such as Avalonia UI, we need to opt in to compiler-generated types, like this:
.AddClasses(classes => classes
// Opt-in to compiler-generated types
.WithAttribute<CompilerGeneratedAttribute>()
// Optionally filter types to reduce number of service registrations.
.InNamespaces("MyApp.Desktop.Views")
.AssignableToAny(
typeof(Window),
typeof(UserControl)
)
.AsSelf()
.WithSingletonLifetime()
With some UI frameworks, these compiler-generated views implement quite a few interfaces, so unless you need them, it's probably best to register these classes .AsSelf(); in other words, be very precise with your filters that accept compiler generated types.
var collection = new ServiceCollection();
// First, add our service to the collection.
collection.AddSingleton<IDecoratedService, Decorated>();
// Then, decorate Decorated with the Decorator type.
collection.Decorate<IDecoratedService, Decorator>();
// Finally, decorate Decorator with the OtherDecorator type.
// As you can see, OtherDecorator requires a separate service, IService. We can get that from the provider argument.
collection.Decorate<IDecoratedService>((inner, provider) => new OtherDecorator(inner, provider.GetRequiredService<IService>()));
var serviceProvider = collection.BuildServiceProvider();
// When we resolve the IDecoratedService service, we'll get the following structure:
// OtherDecorator -> Decorator -> Decorated
var instance = serviceProvider.GetRequiredService<IDecoratedService>();
Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of Scrutor.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Scrutor:
| Package | Downloads |
|---|---|
|
Swashbuckle.AspNetCore.Filters
Some additional useful filters for Swashbuckle.AspNetCore. This package replaces Swashbuckle.AspNetCore.Examples. |
|
|
Scrutor.AspNetCore
Dependency Injection Helper Package For .Net Core Apps |
|
|
Elsa.Core
Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package contains the core of Elsa. Tip: reference the `Elsa` package instead of this one. |
|
|
Sitko.Core.App
Sitko.Core is a set of libraries to help build .NET Core applications fast |
|
|
Convey
Convey |
Showing the top 20 popular GitHub repositories that depend on Scrutor:
| Repository | Stars |
|---|---|
|
LuckyPennySoftware/MediatR
Simple, unambitious mediator implementation in .NET
|
|
|
RayWangQvQ/BiliBiliToolPro
B 站(bilibili)自动任务工具,支持docker、青龙、k8s等多种部署方式。全面拥抱AI。敏感肌也能用。
|
|
|
elsa-workflows/elsa-core
The Workflow Engine for .NET
|
|
|
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
|
|
|
MapsterMapper/Mapster
A fast, fun and stimulating object to object Mapper
|
|
|
ivanpaulovich/clean-architecture-manga
:cyclone: Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks
|
|
|
oskardudycz/EventSourcing.NetCore
Examples and Tutorials of Event Sourcing in .NET
|
|
|
aspnetrun/run-aspnetcore-microservices
Microservices on .NET platforms used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12
|
|
|
vietnam-devs/coolstore-microservices
A full-stack .NET microservices build on Dapr and Tye
|
|
|
microsoft/sbom-tool
The SBOM tool is a highly scalable and enterprise ready tool to create SPDX 2.2 compatible SBOMs for any variety of artifacts.
|
|
|
lookup-foundation/RevitLookup
Interactive Revit RFA and RVT project database exploration tool to view and navigate BIM element parameters, properties and relationships.
|
|
|
meysamhadeli/booking-microservices
A practical microservices with the latest technologies and architectures like Vertical Slice Architecture, Event Sourcing, CQRS, DDD, gRpc, MongoDB, RabbitMq, Masstransit, and Aspire in .Net 10.
|
|
|
thangchung/clean-architecture-dotnet
🕸 Yet Another .NET Clean Architecture, but for Microservices project. It uses Minimal Clean Architecture with DDD-lite, CQRS-lite, and just enough Cloud-native patterns apply on the simple eCommerce sample and run on Tye with Dapr extension 🍻
|
|
|
grandnode/grandnode2
E-commerce platform built with ASP.NET Core using MongoDB for NoSQL storage
|
|
|
roflmuffin/CounterStrikeSharp
CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
|
|
|
matthewrenze/clean-architecture-demo
A sample app for my online course "Clean Architecture: Patterns, Practices, and Principles"
|
|
|
gautema/CQRSlite
A lightweight framework to help creating CQRS and Eventsourcing applications in C#
|
|
|
mehdihadeli/food-delivery-microservices
🍔 A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 9, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
|
|
|
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
|
|
|
snatch-dev/Convey
A simple recipe for .NET Core microservices.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.0 | 6,996,206 | 11/24/2025 |
| 6.1.0 | 12,372,499 | 6/3/2025 |
| 6.0.1 | 12,596,873 | 1/14/2025 |
| 6.0.0 | 274,075 | 1/13/2025 |
| 5.1.2 | 1,020,249 | 1/13/2025 |
| 5.0.3 | 165,648 | 12/23/2024 |
| 5.0.2 | 4,644,904 | 11/7/2024 |
| 5.0.1 | 5,635,050 | 9/26/2024 |
| 5.0.0 | 203,501 | 9/25/2024 |
| 4.2.2 | 39,788,999 | 3/27/2023 |
| 4.2.1 | 3,648,961 | 2/8/2023 |
| 4.2.0 | 17,629,181 | 5/31/2022 |
| 4.1.0 | 6,846,177 | 3/2/2022 |
| 4.0.0 | 2,128,452 | 1/28/2022 |
| 3.3.0 | 108,613,709 | 11/3/2020 |
| 3.2.2 | 5,709,876 | 8/25/2020 |
| 3.2.1 | 6,352,835 | 4/20/2020 |
| 3.2.0 | 2,427,239 | 2/6/2020 |