"He weaves shortcuts into the computer program in a fashion you wouldn't believe." - Isaac Asimov, Nemesis


Wicca v2 transforms .NET applications to enable Aspect-Oriented Programming (AOP) with the goal of improving modularity and evolution, and reducing tedious and error-prone programming. Wicca can transform source code or byte code, at compile-time or runtime (yes, that's right, Wicca can transform the program while it's running). Wicca can also transform a program without modifying it via breakpoint weaving.

This project is headed by Marc Eaddy under the direction of Dr. Alfred Aho.

Weaving Scenarios

Wicca is a hybrid weaver that supports 6 weaving scenarios:

Wicca Weaving Scenarios
Weave Time Weave Strategy* Weaver Supported?
Compile time Byte code Phx.Morph
Source code wcs
Load time Byte code Phx.Morph
Breakpoint Phx.Morph
Source code wcs
Runtime Byte code Phx.Morph
Breakpoint Phx.Morph
Source code wcs
* "Byte code" refers to Microsoft .NET intermediate language (MSIL) code and "source code" refers to C#.

Note: We refer to compile-time weaving as "static weaving" and load-time and runtime weaving as "dynamic weaving".

Static Weaving

The static weaving scenarios are supported by two standalone tools: Phx.Morph and wcs.


Phx.Morph is a static byte-code weaver for .NET applications built on top of Phoenix, Microsoft's back-end compiler infrastructure. To run Phx.Morph from the command-line, you specify it as a plugin for the Microsoft Phoenix pereader.exe assembly rewriting tool. Aspects are specified as regular assemblies with custom [Advice] attributes. The Phx.Morph README file has more information.


Wcs is a source weaver and compiler. It is similar to AspectJ except that it supports C# instead of Java. It can be used standalone via the wcs.exe command-line tool or programmatically via the Wicca.Wcs API. (Wicca currently does not support dynamic source weaving and so does not use the API.) Aspects are specified as regular C# source files with custom [Advice] attributes.

Wcs supports a small extension to C# to enable statement annotations. Here's an example:

	public SimpleDraw() {
		[Log(Sev.Info, "Creating a line")]
		Shape s = new Line(new Point(1, 9), new Point(9, 1));

Wcs uses the standard C# compiler so before compiling it must "encode" the statement annotation using a legal C# method annotation:

	[Statement(19, "LogAttribute", Sev.Info, "Creating a line")]	
	public SimpleDraw() {
		Shape s = new Line(new Point(1, 9), new Point(9, 1));

Wcs and Phx.Morph both recognize this encoding and support advising annotated statements.

Dynamic Weaving

The Wicca dynamic AOP system is implemented as a plug-in for the Microsoft Managed Debugger (mdbg). Mdbg takes care of launching the client process, attaching a debugger to it, managing communication between the debugger and the process, and providing an interactive command-line shell to the user.

Dynamic Byte Code Weaving

Phx.Morph exposes an API to support load-time and runtime weaving ("dynamic weaving"). For dynamic byte code weaving, Phx.Morph weaves the assembly just like in the static weaving case and produces a temporary assembly. Wicca diffs the woven assembly with the currently running program using its AssemblyDiff component and updates it as necessary using the Microsoft Debugger Edit-and-Continue API.

Breakpoint Weaving

For dynamic breakpoint weaving, Phx.Morph weaves the assembly just like in the static weaving case but instead of injecting advice calls, it calls a callback function that Wicca implements. When Wicca gets the callback it sets breakpoints in the running program using the Microsoft Debugger Breakpoint API. When a breakpoint is hit, Wicca obtains the context parameters using the Microsoft Debugger API and then executes the advice method method *in the process space of the running program* using the Microsoft Debugger Func-Eval API.

Dynamic Software Updating

Wicca's diff-and-update API is called AssemblyDiff. AssemblyDiff exposes a general-purpose Dynamic Software Updating (DSU) API that supports (almost) arbitrary updates to the running program via the Microsoft Debugger Edit-and-Continue (EnC) API. The diff process produces a byte code delta file and a metadata delta file which the EnC API consumes. Wicca leverages the API to support three DSU scenarios:

Supported Dynamic Software Update Scenarios
DSU Scenario Summary
Dynamic AOP Phx.Morph automatically creates the woven assembly
Assembly Patch The !patch command is used to supply a new assembly
Delta File Patch The !patch command is used to supply delta files


While the standalone Phx.Morph plugin is fairly mature, the dynamic Wicca AOP system is only an alpha release. Here are some of the major issues: A more detailed issue list can be found in the README file.

Implementation Details

Wicca v1

Wicca v2 is a complete rewrite of v1. It uses the slower out-of- process Microsoft Debugger API instead of the faster in-process Microsoft Profiler API. This rewrite was required to support .NET 2.0. However, there are substantial benefits to using the Debugger API including: Unfortunately, we have not migrated the edit-and-continue, dynamic source weaving, and woven code debugging features to v2 yet. You can still download Wicca v1 here.


Source code and executables for Wicca. Includes a test suite for testing dynamic and static weaving.

Demonstrates how Edit-and-Continue is used to allow the programmer to modify the source code of a 3D game without restarting.

Note: Edit-and-Continue is currently not supported in Wicca v2.


Wicca README file.

Related Publications

Marc Eaddy, Alfred Aho, Weiping Hu, Paddy McDonald, and Julian Burger, "Debugging Aspect-Enabled Programs," to appear in International Symposium on Software Composition (SC 2007), Braga, Portugal, March 25-26, 2007.
Note: This paper refers to features only available in Wicca v1, namely, edit-and-continue and dynamic source weaving.
(Download pdf) Download pdf

Marc Eaddy. "Wicca 2.0: Dynamic Weaving using the .NET 2.0 Debugging APIs," Demonstration at Aspect-Oriented Software Development (AOSD 2007), Vancouver, British Columbia, March 12-16, 2007.
(Download slides) Download slides (pptx) | (Download slides) Download slides (ppt)

Marc Eaddy and Alfred Aho, "Statement Annotations for Fine-Grained Advising," in Proceedings of the 3rd ECOOP Workshop on Reflection, AOP and Meta-Data for Software Evolution (RAM-SE 2006), Nantes, France, July 4, 2006.
(Download pdf) Download pdf

Marc Eaddy, "Phx.Morph: Weaving using the Microsoft Phoenix compiler back-end," Demonstration at Aspect-Oriented Software Development (AOSD 2006), Bonn, Germany, March 20-25, 2006.
(Download slides) Download slides

Marc Eaddy and Steven Feiner, "Multi-Language Edit-and-Continue for the Masses," Technical Report CUCS-015-05, Department of Computer Science, Columbia University, April 2005.
Note: This paper refers to features only available in Wicca v1, namely, edit-and-continue.
(Download pdf) Download pdf | (Download ps) Download ps | (Download video) Download video (18 MB)


Marc Eaddy <me133 AT columbia.edu>