Bernie Cook's Blog

Azure, C#, .NET, Architecture & Related Tech News


Leave a comment

Using dotPeek to Review IL Weaving

dotPeekThere are two types of Aspect Oriented Programming (AOP) in .NET; Interceptors and IL weaving. This post focuses on the later and illustrates how you can use a .NET decompiler to review the code generated by AOP post compilation processing using the IL Weaving approach, albeit the decompiled code.

The most well known AOP framework for .NET is PostSharp, which is what I’ll be using in this post. And one of the more well known .NET decompilers is dotPeek, developed by JetBrains, the company best known in the .NET world for ReSharper. You do have to pay for PostSharp (although there is a trial period), however dotPeek is free and simple to download and execute.

So what I’ve done is provide (1) the source code for a simple .NET console application I’ve knocked together, displaying the resulting decompiled code in dotPeek, then (2) I decorate one of the application’s methods with an AOP aspect and display the resulting decompiled code so you can see what PostSharp has done. Continue reading