Metalama 1.0 / / Metalama Documentation / Post­Sharp API Migration / Post­Sharp.​Aspects.​Advices

Namespace PostSharp.Aspects.Advices

Classes

Advice

AdviceInstance

Advice is not represented by classes in Metalama, but can be added using methods of IAdviceFactory.

AdviceParameterAttribute

In Metalama, there is no declarative way to bind advice parameters. Instead, Metalama uses a programmatic approach, where the advice can get the desired value using the code model. In Metalama, template parameters can be marked as compile-time using CompileTimeAttribute, otherwise they are run-time. Run-time parameters must match the target parameter by name. Compile-time parameters must be supplied by the advice factory method (see IAdviceFactory).

ArgumentAttribute

In Metalama, run-time advice parameters are matched by name, not by index. If you need to get a parameter by index, use meta.Target.Parameters[index].Value. from the template.

ArgumentsAttribute

In Metalama, do not use a parameter but use meta.Target.Parameters.Values.ToArray() from the template implementation.

AspectInitializationReason

There is no equivalent to this advice in Metalama because there is no concept of run-time aspect initialization.

AsyncCallIdAttribute

There is no equivalent in Metalama. You need to generate, in the template, code that assigns a local variable to a value that is unique within the process.

AwaitedMethodAttribute

There is no equivalent in Metalama, and there is currently no way to implement this feature differently.

AwaitedTaskAttribute

There is no equivalent in Metalama, and there is currently no way to implement this feature differently.

AwaiterAttribute

There is no equivalent in Metalama, and there is currently no way to implement this feature differently.

BindingAttribute

Bindings do not exist in Metalama. Instead, use invokers (e.g. IMethod.Invokers) to generate run-time code that invokes the desired method or accesses the property or event.

CopyCustomAttributesAttribute

In Metalama, all custom attributes except Metalama ones are copied from the template to the introduced declaration.

CurrentTaskAttribute

There is no equivalent in Metalama, and there is currently no way to implement this feature differently.

CustomAttributeOverrideAction

In Metalama, use OverrideStrategy.

DeclarationIdentifierAttribute

There is no equivalent to this feature in Metalama, but you can use a template to generate equivalent code.

DeclarationNameAttribute

In Metalama, use the IMember.Name property.

Event<TDelegate>

In PostSharp, this class allowed the run-time code of the aspect to access an event in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IEvent.Invokers to generate run-time code for any event.

EventAccessor<TDelegate>

In PostSharp, this delegate allowed the run-time code of the aspect to access an event in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IEvent.Invokers to generate run-time code for any event.

FlowBehaviorAttribute

In Metalama, there is no need for FlowBehavior because the template is in full control of the generated code.

GroupingAdvice

ImportLocationAdviceInstance

In Metalama, members of the target declaration do not need to be imported into the aspect. Instead, the aspect accesses the target code using dynamic code or invokers. To generate code that accesses a field or property, use IFieldOrProperty.Invokers or IFieldOrProperty.ToExpression(IFieldOrProperty, IExpression).Value.

ImportMemberAdviceInstance

In Metalama, members of the target declaration do not need to be imported into the aspect. Instead, the aspect accesses the target code using dynamic code or invokers.

ImportMemberAttribute

In Metalama, members of the target declaration do not need to be imported into the aspect. Instead, the aspect accesses the target code using dynamic code or invokers. To generate code that calls a method, use IMethod.Invokers. To generate code that accesses a field or property, use IFieldOrProperty.Invokers or IFieldOrProperty.ToExpression(IFieldOrProperty, IExpression).Value.

ImportMemberOrder

In Metalama, equivalent to InvokerOrder. You can pass an InvokerOrder to the IInvokerFactory<T>.GetInvoker(InvokerOrder, InvokerOperator) method.

ImportMethodAdviceInstance

In Metalama, members of the target declaration do not need to be imported into the aspect. Instead, the aspect accesses the target code using dynamic code or invokers. To generate code that calls a method, use IMethod.Invokers.

InitializeAspectInstanceAdvice

In Metalama, use builder.Advice.AddInitializer(INamedType, String, InitializerKind, Object, Object).

InterfaceOverrideAction

In Metalama, equivalent to OverrideStrategy.

IntroduceInterfaceAdviceInstance

In Metalama, use builder.Advice.ImplementInterface(INamedType, INamedType, OverrideStrategy, Object).

IntroduceInterfaceAttribute

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and call builder.Advice.ImplementInterface(INamedType, INamedType, OverrideStrategy, Object).

IntroduceMemberAdviceInstance

In Metalama, call one of the Introduce methods of builder.Advice.

IntroduceMemberAttribute

In Metalama, use the IntroduceAttribute custom attribute.

IntroduceMethodAdviceInstance

In Metalama, call the builder.Advice.IntroduceMethod(INamedType, String, IntroductionScope, OverrideStrategy, Action<IMethodBuilder>, Object, Object) method.

LocationValidationAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and call builder.Advice.AddContract(IParameter, String, ContractDirection, Object, Object).

LocationValueAttribute

In a template applied to a field or property, the field or property value can be represented as a parameter named value. The type of this parameter must be dynamic or be compatible with the field or property type.

MatchPointcut

In Metalama, use a foreach loop in the BuildAspect(IAspectBuilder<T>) method, iterate builder.Target.INamedType.Methods, and add advice using methods of builder.Advice.

MemberOverrideAction

In Metalama, equivalent to OverrideStrategy.

MethodPointcut

In Metalama, use a foreach loop in the BuildAspect(IAspectBuilder<T>) method, iterate the code model exposed on builder.Target, and add advice using methods of builder.Advice.

MulticastPointcut

In Metalama, you should use a programmatic approach. Use a foreach loop in the BuildAspect(IAspectBuilder<T>) method, iterate the code model exposed on builder.Target, and add advice using methods of builder.Advice.

OnAspectsInitializedAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.AddInitializer(INamedType, String, InitializerKind, Object, Object).

OnEventAddHandlerAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.OverrideAccessors(IEvent, String, String, String, Object, Object)

OnEventInvokeHandlerAdvice

There is no equivalent to this feature in Metalama.

OnEventRemoveHandlerAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.OverrideAccessors(IEvent, String, String, String, Object, Object)

OnInstanceConstructedAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.AddInitializer(INamedType, String, InitializerKind, Object, Object).

OnInstanceLocationInitializedAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.AddInitializer(INamedType, String, InitializerKind, Object, Object).

OnLocationGetValueAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.OverrideAccessors(IFieldOrProperty, in GetterTemplateSelector, String, Object, Object) or Override(IFieldOrProperty, String, Object)

OnLocationSetValueAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.OverrideAccessors(IFieldOrProperty, in GetterTemplateSelector, String, Object, Object) or Override(IFieldOrProperty, String, Object)

OnMethodBoundaryAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodEntryAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodExceptionAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodExitAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodInvokeAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodInvokeAsyncAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodInvokeBaseAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodResumeAdvice

There is no equivalent to this advice in Metalama and it is currently not possible to build the equivalent feature.

OnMethodSuccessAdvice

In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder.Advice.Override(IMethod, in MethodTemplateSelector, Object, Object).

OnMethodYieldAdvice

There is no equivalent to this advice in Metalama and it is currently not possible to build the equivalent feature.

Pointcut

In Metalama, use a foreach loop in the BuildAspect(IAspectBuilder<T>) method, iterate the code model exposed on builder.Target, and add advice using methods of builder.Advice.

Property<TValue>

In PostSharp, this class allowed the run-time code of the aspect to access a property in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IProperty.Invokers or IProperty.ToExpression(IFieldOrProperty, IExpression).Value to generate run-time code for any event.

Property<TValue, TIndex>

In PostSharp, this class allowed the run-time code of the aspect to access a property in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IProperty.Invokers or IProperty.ToExpression(IFieldOrProperty, IExpression).Value to generate run-time code for any event.

PropertyGetter<TValue>

In PostSharp, this delegate allowed the run-time code of the aspect to access a property in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IProperty.Invokers or IProperty.ToExpression(IFieldOrProperty, IExpression).Value to generate run-time code for any event.

PropertyGetter<TValue, TIndex>

In PostSharp, this delegate allowed the run-time code of the aspect to access a property in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IProperty.Invokers or IProperty.ToExpression(IFieldOrProperty, IExpression).Value to generate run-time code for any event.

PropertySetter<TValue>

In PostSharp, this delegate allowed the run-time code of the aspect to access a property in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IProperty.Invokers or IProperty.ToExpression(IFieldOrProperty, IExpression).Value to generate run-time code for any event.

PropertySetter<TValue, TIndex>

In PostSharp, this delegate allowed the run-time code of the aspect to access a property in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IProperty.Invokers or IProperty.ToExpression(IFieldOrProperty, IExpression).Value to generate run-time code for any event.

ReturnValueAttribute

In Metalama, call meta.Proceed in the template and store the value in a local variable.

SelfPointcut

In Metalama, use a foreach loop in the BuildAspect(IAspectBuilder<T>) method,use advice using methods of builder.Advice and pass builder.Target as the target declaration.

SignaturePointcut

In Metalama, use a foreach loop in the BuildAspect(IAspectBuilder<T>) method, iterate the code model exposed on builder.TargetMethods, and add advice using methods of builder.Advice.

StateAttribute

In Metalama, use a local variable in the template.

StateScope

No equivalent in Metalama.

ThisAttribute

In Metalama, use meta.This in the template.

Interfaces

IAdviceProvider

In Metalama, implement the BuildAspect(IAspectBuilder<T>) and use the methods of the IAdviceFactory interface exposed on IAspectBuilder<TAspectTarget>.Advice.

IProperty

In PostSharp, this interface allowed the run-time code of the aspect to access a property in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IProperty.Invokers or IProperty.ToExpression(IFieldOrProperty, IExpression).Value to generate run-time code for any event.