Skip to content

OnMethodBoundaryAspect

Sagi edited this page Aug 10, 2015 · 8 revisions

An aspect that when applied on a method, inserts pieces of code before and after the execution of the method.

In order to apply an aspect on a method the first thing you need to do is write the aspect itself.
You need to create a class that derives from one of these types:


NCop differentiates between functions and subroutines the same way as the .NET delegates (System.Func<T>, System.Action).

If you want to create an aspect for a subroutine (method that returns void in C# or Sub in VB) you will need to derive from OnActionBoundaryAspect and to derive from OnFunctionBoundaryAspect for a function.

NCop supports methods that has up until 8 parameters:
For OnActionBoundaryAspect

OnActionBoundaryAspect
OnActionBoundaryAspect<TArg1>
OnActionBoundaryAspect<TArg1, TArg2>
OnActionBoundaryAspect<TArg1, TArg2, TArg3>
OnActionBoundaryAspect<TArg1, TArg2, TArg3, TArg4>
OnActionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5>
OnActionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>
OnActionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>
OnActionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>

For OnFunctionBoundaryAspect

OnFunctionBoundaryAspect<TResult>
OnFunctionBoundaryAspect<TArg1, TResult>
OnFunctionBoundaryAspect<TArg1, TArg2, TResult>
OnFunctionBoundaryAspect<TArg1, TArg2, TArg3, TResult>
OnFunctionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TResult>
OnFunctionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>
OnFunctionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>
OnFunctionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>
OnFunctionBoundaryAspect<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>