Compile-Time Weaving

There are basically three ways to modify the behavior of a .NET programs during the build phase:

Source-Level Weaving

You have to parse the source code, modify it and compile it using a standard compiler. The disadvantage is that you have to write a parser-renderer for each of the targeted languages. But you have the possibility to add constructions to the syntax.

Tools:

Writing your own compiler

You can start from scratch or use from an existing open-source compiler like gcc or Mono. The disadvantage is clearly that you have to write your own compiler or extend an existing... and who can afford it? But, at this price, you can do virtually what you want.

Tools:

Modifying the MSIL code

Let the standard compiler do its job, then read the compiled assembly, modify it and write it back. This is the approach of PostSharp.

Tools: