The weaver takes an aspect assembly and weaves the aspects into an input assembly and stores and output assembly.
The output assembly is intended to replace the input assembly.
As part of the process a socalled glue assembly is generated with some code to glue the input/output assembly and the aspect assembly together.
Aspects are normal C# code and are build like normal.
The yaaaopf command line utility accepts /ia: switches for input assemblies (assemblies to be modified), /aa: switches for aspect assemblies (assmblies with aspects) and /ga: switch for generated glue assmbly (default is YaaaopfGlue.dll).
using System; using Vajhoej.StaticWeaver; namespace Demo { [Aspect] public class TestAspect { [Pointcut(Signature="* *::*(*)")] public static void TestPointcut() { } [BeforeCallAdvice(Pointcut="TestPointcut")] public static void EntryLog(MethodJoinpoint mjp) { Console.WriteLine("Enter " + mjp.TypeName + "." + mjp.MethodName); int ix = 1; foreach(object o in mjp.Arguments) { Console.WriteLine(" arg " + ix + " = " + o); ix++; } } [AfterCallAdvice(Pointcut="TestPointcut")] public static void ExitLog(MethodJoinpoint mjp) { Console.WriteLine("Exit " + mjp.TypeName + "." + mjp.MethodName); if(mjp.Result != null) Console.WriteLine(" retval = " + mjp.Result); } } }
Utility:
yaaopf /ia:CodeToBeModified.dll /aa:Aspects.dll /ga:Glue.dll
Note that yaaopf utility leave input assembly as is (CodeToBeModified.dll) and store output assmbly under new name (CodeToBeModified.dll_yaaopf) - you need manually to copy the output over to input.
Wrapper:
yaaopf1 CodeToBeModified.dll Aspects.dll Glue.dll
Note that yaaopf1 wrapper automatically renames the input assembly (to CodeToBeModified.dll_backup) and renames the output assembly to the original name.
It is tested against very simple examples of:
It is not tested against any advanced stuff: params keyword, optional & named arguments, unnamed types, dynamic, COM, AppDomain's etc..