Open sandboxFocus

Class OnMethodExitAdvice

Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice that has the same semantics as OnExit(MethodExecutionArgs).

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp.dll
Syntax
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class OnMethodExitAdvice : OnMethodBoundaryAdvice
Remarks

The method to which this custom attribute is applied must be public and must return void. It can be static. Each parameter of the method receives a value of the target, selected by a custom attribute derived from AdviceParameterAttribute, such as ReturnValueAttribute or StateAttribute. Alternatively, the method can have the same signature as OnExit(MethodExecutionArgs), whose MethodExecutionArgs parameter is allocated on each call. The MethodExecutionArgs parameter can also be the first parameter, followed by bound parameters.


If an aspect defines many advices (among OnMethodEntryAdvice , OnMethodExitAdvice , OnMethodSuccessAdvice and OnMethodExceptionAdvice ) that are meant to be applied to the same methods with consistent ordering, these advices should be grouped together (see Master property).

note

A master advice without a custom attribute derived from Pointcut applies to the method or constructor to which the aspect is applied; when the aspect is applied to another kind of declaration, a pointcut is required. An advice without Master and without pointcut joins the group of the master advice declared in its class.

Constructors

Name Description
OnMethodExitAdvice()

See Also