Franz.Common.DependencyInjection
2.3.1
See the version list below for details.
dotnet add package Franz.Common.DependencyInjection --version 2.3.1
NuGet\Install-Package Franz.Common.DependencyInjection -Version 2.3.1
<PackageReference Include="Franz.Common.DependencyInjection" Version="2.3.1" />
<PackageVersion Include="Franz.Common.DependencyInjection" Version="2.3.1" />
<PackageReference Include="Franz.Common.DependencyInjection" />
paket add Franz.Common.DependencyInjection --version 2.3.1
#r "nuget: Franz.Common.DependencyInjection, 2.3.1"
#:package Franz.Common.DependencyInjection@2.3.1
#addin nuget:?package=Franz.Common.DependencyInjection&version=2.3.1
#tool nuget:?package=Franz.Common.DependencyInjection&version=2.3.1
Franz.Common.DependencyInjection
Shared framework capability for the Franz.Common framework on .NET 10.
Overview
The Franz.Common.DependencyInjection package provides shared framework capability within Franz.Common. It is designed to compose with the rest of the framework rather than imposing unrelated infrastructure choices on every application.
Installation
dotnet add package Franz.Common.DependencyInjection
Design principles
- Explicit composition: register only the capabilities the application needs.
- Clear boundaries: keep domain and application contracts independent from provider-specific infrastructure where the package's role permits it.
- Predictable behavior: make configuration, failure modes, and lifecycle ownership visible rather than relying on hidden conventions.
- Operational readiness: validate security, resilience, diagnostics, and compatibility for the actual deployment environment.
Usage and configuration
Follow the package-specific setup, configuration, and code examples below. Only configure external services when this package requires them, and keep secrets outside source control.
Package-specific guide
A core library within the Franz Framework, designed to simplify and enhance the usage of dependency injection in .NET applications. This package provides utilities and extensions for efficient registration of services, managing lifetimes, and ensuring clean dependency resolution.
Features
1. Service Registration
- Scoped Dependencies:
- Automatically registers services implementing
IScopedDependencywith scoped lifetimes.
- Automatically registers services implementing
- Singleton Dependencies:
- Registers services implementing
ISingletonDependencywith singleton lifetimes.
- Registers services implementing
- Reflection-Based Registration:
- Automatically registers services based on custom reflection rules using
ITypeSourceSelectorExtensions.
- Automatically registers services based on custom reflection rules using
2. Custom Strategies
- RegistrationStrategySkipExistingPair:
- Prevents duplicate service registrations, ensuring efficient dependency management.
3. Modular Integration
- Advanced Assembly Filtering:
- Filters assemblies using
FromCompanyApplicationDependenciesWithPredicatefor targeted registration.
- Filters assemblies using
- Flexible Service Types:
- Supports scoped, singleton, and transient registrations with various interfaces and class hierarchies.
Version Information
Current Version: v2.3.0
- Part of the private Franz Framework ecosystem.
Dependencies
This package relies on:
- Microsoft.Extensions.DependencyInjection.Abstractions: Provides the core interfaces for dependency injection.
- Scrutor (4.2.2): Enables advanced scanning and automatic service registration.
- Franz.Common: Supplies core utilities for the framework.
- Franz.Common.Reflection: Adds reflection utilities for enhanced DI support.
Installation
From Private Azure Feed
Since this package is hosted privately, configure your NuGet client:
dotnet nuget add source "https://your-private-feed-url" \
--name "AzurePrivateFeed" \
--username "YourAzureUsername" \
--password "YourAzurePassword" \
--store-password-in-clear-text
Install the package:
dotnet add package Franz.Common.DependencyInjection
Usage
1. Core Service Registration
Use the ServiceCollectionExtensions to register common dependencies based on their interfaces and lifetimes:
Register Scoped Dependencies
Automatically register all classes implementing IScopedDependency:
using Franz.Common.DependencyInjection.Extensions;
services.AddScopedDependencies();
Register Singleton Dependencies
Automatically register all classes implementing ISingletonDependency:
using Franz.Common.DependencyInjection.Extensions;
services.AddSingletonDependencies();
Add Dependencies with Custom Assembly Filtering
Use a custom predicate to filter assemblies:
services.AddDependencies(assembly => assembly.GetName().Name.Contains("MyApp"));
2. Advanced Registration Patterns
Prevent Duplicate Registrations
Avoid redundant registrations using RegistrationStrategySkipExistingPair:
using Franz.Common.DependencyInjection.Extensions;
services.AddWithStrategy<ILogger, Logger>(new RegistrationStrategySkipExistingPair());
Reflection-Based Registration
Automatically register services based on reflection:
services.Scan(scan => scan
.FromCompanyApplicationDependenciesWithPredicate(assembly => assembly.GetName().Name.StartsWith("MyCompany"))
.AddClasses(classes => classes.AssignableTo<IService>())
.AsImplementedInterfaces()
.WithScopedLifetime());
Custom Registration for Self and Matching Interfaces
Register services with custom rules:
services.AddSelfScoped<IOrderService>();
services.AddMatchingInterfaceScoped<IOrderService>();
services.AddImplementedInterfaceSingleton<IOrderService>();
3. Custom Extension Points
Add No-Duplicate Services
Ensure no duplicate services are added:
services.AddNoDuplicateScoped<IOrderService, OrderService>();
services.AddNoDuplicateSingleton<ILogger, Logger>();
services.AddNoDuplicateTransient<IService, ServiceImplementation>();
Add Inherited Class Registration
Register classes inheriting from a specific base type:
services.AddInheritedClassSingleton<MyBaseType>();
Integration with Franz Framework
The Franz.Common.DependencyInjection package integrates seamlessly with:
- Franz.Common: Provides foundational utilities.
- Franz.Common.Reflection: Enables advanced assembly and type filtering for DI registration.
Contributing
This package is part of a private framework. Contributions are limited to the internal development team. If you are authorized to contribute:
- Clone the repository. @ https://github.com/bestacio89/Franz.Common/
- Create a feature branch.
- Submit a pull request for review.
License
This library is licensed under the MIT License. See the LICENSE file for more details.
Changelog
Version 1.3
- Upgraded to .NET 9.0.8
- Added new features and improvements
- Separated business concepts from mediator concepts
- Now compatible with both the in-house mediator and MediatR
Version 1.3.6
- DI glue isolated here — core is DI-free.
- AddFranzMediator(), AddFranzMessaging(), etc. live here.
- Microsoft DI = optional adapter (others possible).
Version 1.6.20
- Updated to .NET 10.0
v2.0.1 – Internal Modernization
- Messaging and infrastructure refactored for async, thread-safety, and modern .NET 10 patterns.
- All APIs remain fully backward compatible.
- Tests, listeners, and pipeline components modernized.
Dependency maintenance — October 2026
This project's dependency references were reviewed and updated as part of the repository-wide .NET 10 maintenance pass. The intended target framework and public API remain unchanged. Verify the resolved direct and transitive dependency graph through the repository's dependency validation workflow before publishing. See the central dependency upgrade record.
| Product | Versions 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. |
-
net10.0
- Franz.Common (>= 2.3.1)
- Franz.Common.Reflection (>= 2.3.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Scrutor (>= 7.0.0)
NuGet packages (16)
Showing the top 5 NuGet packages that depend on Franz.Common.DependencyInjection:
| Package | Downloads |
|---|---|
|
Franz.Common.Business
Shared utility library for the Franz Framework. |
|
|
Franz.Common.Headers
Shared utility library for the Franz Framework. |
|
|
Franz.Common.Serialization
Shared utility library for the Franz Framework. |
|
|
Franz.Common.Messaging
Shared utility library for the Franz Framework. |
|
|
Franz.Common.Hosting
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.2 | 0 | 10/27/2026 |
| 2.3.1 | 168 | 10/26/2026 |
| 2.3.0 | 656 | 7/21/2026 |
| 2.2.19 | 542 | 7/19/2026 |
| 2.2.18 | 544 | 7/19/2026 |
| 2.2.17 | 825 | 7/12/2026 |
| 2.2.16 | 542 | 7/2/2026 |
| 2.2.15 | 547 | 6/29/2026 |
| 2.2.14 | 551 | 6/29/2026 |
| 2.2.13 | 559 | 6/29/2026 |
| 2.2.12 | 537 | 6/28/2026 |
| 2.2.11 | 548 | 6/28/2026 |
| 2.2.10 | 542 | 6/28/2026 |
| 2.2.9 | 540 | 6/28/2026 |
| 2.2.8 | 673 | 6/28/2026 |
| 2.2.7 | 546 | 6/7/2026 |
| 2.2.6 | 545 | 6/6/2026 |
| 2.2.5 | 569 | 6/4/2026 |
| 2.2.4 | 543 | 6/3/2026 |
| 2.2.3 | 536 | 6/2/2026 |