Compile-Time Weaving
There are basically three ways to modify the behavior of a .NET programs during the build phase:
Source-Level Weaving
This method requires parsing the source code, modifying it, and then compiling it using a standard compiler. The disadvantage is that a parser-renderer must be written for each of the targeted languages. However, this method allows for the addition of constructions to the syntax.
Tools:
Writing Your Own Compiler
You can either start from scratch or use an existing open-source compiler like gcc or Mono. The clear disadvantage is that you need to write your own compiler or extend an existing one, which may not be feasible for everyone. However, this approach provides virtually unlimited possibilities.
Tools:
Modifying the MSIL code
Allow the standard compiler to complete its job, then read the compiled assembly, modify it, and write it back. This is the approach utilized by PostSharp.
Tools:
- PostSharp
- Aspect.NET . This tool relies on Phoenix.
- AspectDNG . This tool relies on Cecil.
- ComposeStar / StarLight
- Gripper Loom.NET
- Phx.Morph/Wicca . This tool relies on Phoenix.