开发者

PostSharp vs DynamicProxy2 Interface Interception

I've used PostSharp in the past to do AOP and I've been checking out AOP using Auto开发者_JS百科fac and DynamicProxy2 and I'm curious if there are any benefits of one of the other.

i.e. Is one more reliable, testable, stable, performant, etc, etc than the other?

Thanks.


To better explain what @jgauffin said, PostSharp uses MSIL rewriting after the compiler builds your C# and inserts the code you wrote into the specific pointcuts you set for the aspect. PostSharp goes beyond that though and does many smart optimization checks to help squeeze the most performance out. See http://programmersunlimited.wordpress.com/2011/03/23/postsharp-weaving-community-vs-professional-reasons-to-get-a-professional-license/ for more info about that.

DynamicProxy2 is JIT-emitted which means runtime. IMO if you're just dealing with cross-cutting concerns then use a compile time AOP framework like PostSharp. But if you need to have dynamic changes at runtime then PostSharp isn't for you.


PostSharp is run at compile time, so it should be faster. (It inject it's code to your assemblies)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜