Binds a parameter of a method boundary advice to a FlowBehavior variable, which the advice sets to change the control flow of the target method.
Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp.dll
Syntax
public sealed class FlowBehaviorAttribute : AdviceParameterAttributeRemarks
The parameter must be of type FlowBehavior, and it must be ref or out. The compiler reads the variable after
OnMethodEntryAdvice, OnMethodExceptionAdvice and OnMethodResumeAdvice. The value has no effect in the other advices.
With Return, the method returns the value assigned to the out or ref parameter bound by
ReturnValueAttribute. When the advice has no such parameter, the method returns ReturnValue
if the advice has a MethodExecutionArgs parameter, and the default value of its return type otherwise.
In OnMethodExceptionAdvice, ThrowException throws the exception held by the out or ref
parameter bound by ExceptionAttribute, which the advice can replace. Without such a parameter, it throws
Exception or the caught exception, with a throw instruction, not a rethrow instruction.
Yield requires a parameter bound by AwaiterAttribute.
In OnMethodExceptionAdvice, Continue behaves like Return. In an entry or resume advice of an async method, a parameter bound by this attribute without a parameter bound by AwaiterAttribute causes a build warning, because the advice cannot use Yield.
When the advice also has a MethodExecutionArgs parameter, the value of the parameter bound by this attribute is used, and FlowBehavior is ignored.
Constructors
| Name | Description |
|---|---|
| FlowBehaviorAttribute() |