Binds a parameter of a method interception or method boundary advice to the return value of the target method.
Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp.dll
Syntax
public sealed class ReturnValueAttribute : AdviceParameterAttributeRemarks
The type of the parameter must be the type of the return value, or a type parameter of the advice method. In an async method that a method boundary advice applies to as a state machine, and in a non-async method that returns a task, the return value is the result of the task. An advice can have only one parameter bound by this attribute.
The meaning of the parameter depends on the advice:
- In an OnMethodInvokeAdvice, the parameter must be
outorref, and the value that the advice assigns to it is the value returned by the target method. An advice applied to a method that returns a value must have either a parameter bound by this attribute or a MethodInterceptionArgs parameter. - In an OnMethodSuccessAdvice or an OnMethodExitAdvice, the advice reads the value that the
method returns, by value or
in, or replaces it withref. When the method throws, the exit advice reads the default value. - In an OnMethodEntryAdvice or an OnMethodExceptionAdvice, the parameter must be
outorref. It sets the value that the method returns when the advice sets the flow behavior to Return.
In a method boundary advice, an out or ref parameter takes precedence over ReturnValue
when the advice has both.
Constructors
| Name | Description |
|---|---|
| ReturnValueAttribute() |
Properties
| Name | Description |
|---|---|
| IsRequired | Gets or sets a value indicating whether the target method of a method boundary advice must have a return value. When this property is
|