A high-performance Aspect-Oriented Programming (AOP) framework for .NET
Welcome to BeyondNet.Aop! This framework allows you to implement cross-cutting concerns (such as logging, retries, caching, etc.) cleanly and efficiently using .NET's native DispatchProxy, augmented with high-performance caching for reflection and dynamic compilation.
# Core AOP library
dotnet add package BeyondNetCode.Shell.Aop
# Pre-built aspects (retry, logging, etc.)
dotnet add package BeyondNetCode.Shell.Aop.Aspects
# Serilog integration (recommended for observability)
dotnet add package BeyondNetCode.Shell.Aop.Aspects.Logger.Serilog
# Dependency Injection installer
dotnet add package BeyondNetCode.Shell.Aop.DI| Package | Description | NuGet |
|---|---|---|
BeyondNetCode.Shell.Aop |
Core AOP abstractions and executor | link |
BeyondNetCode.Shell.Aop.Aspects |
Pre-built retry, logger, and advice aspects | link |
BeyondNetCode.Shell.Aop.Aspects.Logger |
Common.Logging integration | link |
BeyondNetCode.Shell.Aop.Aspects.Logger.Serilog |
Serilog integration with structured logging | link |
BeyondNetCode.Shell.Aop.DispatchProxy |
Native DispatchProxy-based proxy creation | link |
BeyondNetCode.Shell.Aop.DI |
Microsoft.Extensions.DependencyInjection extensions | link |
// 1. Define your aspect attribute
[AttributeUsage(AttributeTargets.Method)]
public class RetryAttribute : AbstractAspectAttribute
{
public int MaxRetries { get; set; } = 3;
public int DelayMs { get; set; } = 1000;
}
// 2. Implement your aspect
public class RetryAspect : OnMethodBoundaryAspect<RetryAttribute>
{
protected override void OnEntry(IJoinPoint joinPoint)
{
Console.WriteLine($"Entering {joinPoint.MethodInfo.Name}");
}
protected override void OnException(IJoinPoint joinPoint, Exception ex)
{
// Implement retry logic
}
}
// 3. Apply to your interface
public interface IMyService
{
[Retry(MaxRetries = 3)]
Task<string> DoSomethingAsync();
}
// 4. Register in DI
services.AddAopAspects(typeof(IMyService).Assembly);For detailed documentation, see the language-specific README files:
If you were using Ums.Shell.Aop, update your NuGet references:
# Before (Ums.Shell.Aop)
dotnet add package Ums.Shell.Aop
# After (BeyondNetCode.Shell.Aop)
dotnet add package BeyondNetCode.Shell.AopUpdate namespaces in your code:
// Before
using Ums.Shell.Aop;
// After
using BeyondNetCode.Shell.Aop;See CONTRIBUTING.md for GitFlow workflow, commit conventions, and coding standards.
See VERSIONING.md for SemVer strategy and release process.
Licensed under the Apache 2.0 License. See LICENSE for details.
See DISCLAIMER.md for original code authorship attribution.