geoder101.Microsoft.Extensions.DependencyInjection 1.0.6-alpha

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

DependencyInjection.Microsoft

DI extension helpers for Microsoft.Extensions.DependencyInjection that simplify service registration, lifetime preservation, and composition.

NuGet

Overview

This library extends Microsoft.Extensions.DependencyInjection with powerful composition capabilities, enabling you to enhance registered services with additional functionality while preserving their original lifetimes. Build flexible, maintainable applications by layering cross-cutting concerns like logging, caching, validation, and more onto your services.

Installation

dotnet add package geoder101.Microsoft.Extensions.DependencyInjection

Quick Start

Basic Decorator

using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();

// Register your service
services.AddTransient<INotificationService, EmailNotificationService>();

// Decorate it with logging
services.Decorate<INotificationService, LoggingNotificationDecorator>();

var provider = services.BuildServiceProvider();
var notificationService = provider.GetRequiredService<INotificationService>();
// Returns LoggingNotificationDecorator wrapping EmailNotificationService

Decorator with Factory

services.AddScoped<IOrderProcessor, OrderProcessor>();

// Use factory to access IServiceProvider
services.Decorate<IOrderProcessor>((provider, inner) =>
{
    var logger = provider.GetRequiredService<ILogger<OrderProcessorDecorator>>();
    return new OrderProcessorDecorator(inner, logger);
});

Chaining Multiple Decorators

services.AddTransient<ICalculator, Calculator>();

// Add multiple decorators - they wrap in order
services.Decorate<ICalculator, CachingCalculatorDecorator>();
services.Decorate<ICalculator, LoggingCalculatorDecorator>();
services.Decorate<ICalculator, ValidationCalculatorDecorator>();

// Result: ValidationCalculatorDecorator -> LoggingCalculatorDecorator -> CachingCalculatorDecorator -> Calculator

Use Cases

The decorator pattern is ideal for adding cross-cutting concerns to your services:

  • Logging - Track method calls, parameters, and results
  • Caching - Add response caching to expensive operations
  • Validation - Validate inputs before calling the actual service
  • Retry Logic - Add resilience with automatic retries
  • Performance Monitoring - Track execution time and metrics
  • Authorization - Add security checks before method execution

Documentation

📚 Decorator Pattern Guide - Comprehensive documentation including:

  • Complete API reference
  • Real-world examples (logging, caching, retry, validation, metrics)
  • Service lifetime behavior
  • Best practices and common patterns
  • Troubleshooting guide

Project Structure

DependencyInjection.Microsoft/
├── src/
│   ├── DependencyInjection.Microsoft/          # Main library
│   └── DependencyInjection.Microsoft.UnitTests/ # Unit tests
├── docs/
│   └── Decorator.md                             # Detailed documentation
└── README.md                                    # This file

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.


Co-authored with Artificial Intelligence

This repository is part of an ongoing exploration into human-AI co-creation.
The code, comments, and structure emerged through dialogue between human intent and LLM reasoning — reviewed, refined, and grounded in human understanding.

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 (1)

Showing the top 1 NuGet packages that depend on geoder101.Microsoft.Extensions.DependencyInjection:

Package Downloads
geoder101.MoqProxy.DependencyInjection.Microsoft

Microsoft.Extensions.DependencyInjection integration for MoqProxy. Enables wrapping DI-registered services with Moq proxies for testing - verify calls to real implementations, spy on service interactions, and test integration scenarios without modifying production code.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6-alpha 115 10/20/2025
1.0.2-alpha 120 10/19/2025
1.0.1-alpha 115 10/19/2025