How to Choose an AOP Framework?
Return to Contents
4. How to Choose an AOP Framework?
4.1 DynamicProxy or IL Level Weaving
Generally, the AOP frameworks mentioned in last chapter can be divided into two categories: DynamicProxy and IL Level Weaving.
4.1.1 DynamicProxy
An AOP framework based on DynamicProxy, like Aspect#, dynamically (at runtime) constructs and builds sub classes of classes wanted to be intercepted with advices according to the configurations. Because it depends on inheritance, there come some implicit constraints: classes wanted to be intercepted must be un-sealed (inheritable); methods or properties of classes wanted to be intercepted must be virtual (overridable). In fact, an AOP framework of this kind is an extension of the DynamicProxy Pattern, including a set of configuration language and helper and factory classes for creating proxy objects or doing advising and introducing. For more about DynamicProxy Pattern, see Castle Project/DynamicProxy.
4.1.2 IL Level Weaving
Different from
4.2 Different Configuration Methods
Each AOP framework must have its specific configuration language. Although the format of a configuration language may mot affect much of the performance and implementing essence of the framework, it is the user interface of the framework and it represents how easy it is for users to use the AOP framework. There are four most common configuration methods:
- Custom script like configuration language, e.g. Aspect#.
- Xml based configuration, e.g. AspectDNG.
- Custom Attribute Classes based Configuration, e.g. PapierLoom.Net (Dynamic Part of Loom.Net)
- AspectJ like specific programming language extension with extended compiler, e.g. Eos.
4.3 Suggestion
How to choose the most suitable AOP framework for your project depends on the facts of your project.
If your project is a completely new one from design, which means your project doesn't depend on lots of existing codes, then all mentioned frameworks are suitable. So you should just choose the most familiar and the most stable one. And I suggest Aspect# and AspectDNG.
If your new project based on lots of existing code that expensive to change or based on existing assemblies without source code, AOP frameworks based on IL level weaving become the only choice. And I suggest AspectDNG.
Briefly, If you are not sure which one to choose, choose an IL level weaving based framework will not be too worse. And I suggest AspectDNG.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构