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.ToValueArray() from the template implementation.
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.IMethod.Invoke(object[])) 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.
DeclarationIdentifierAttribute
There is no equivalent to this feature in Metalama, but you can use a template to generate equivalent code.
DeclarationNameAttribute
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 invokers (e.g. IEvent.Add(dynamic?)) 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.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.IMethod.Invoke(object[]). To generate code that accesses a field or property, use IFieldOrProperty.IFieldOrProperty.Value.
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.Invoke(params dynamic?[]).
InitializeAspectInstanceAdvice
In Metalama, use builder
.Advice.AddInitializer(INamedType, string, InitializerKind, object?, object?).
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.
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.
OnLocationSetValueAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder
.Advice.OverrideAccessors(IEvent, string?, string?, string?, object?, object?)
or Override(IFieldOrProperty, string, object?)
OnMethodBoundaryAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder
.Advice.OverrideAccessors(IEvent, string?, string?, string?, object?, object?).
OnMethodEntryAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use
builder
.Advice.
OnMethodExceptionAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use
builder
.Advice.
OnMethodExitAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use
builder
.Advice.
OnMethodInvokeAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use
builder
.Advice.
OnMethodInvokeAsyncAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use
builder
.Advice.
OnMethodInvokeBaseAdvice
In Metalama, implement the BuildAspect(IAspectBuilder<T>) method and use builder
.Advice.Override(IFieldOrProperty, string, 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.
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.Value to generate run-time code for any property.
Property<TValue, TIndex>
In PostSharp, this class allowed the run-time code of the aspect to access an indexer in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IIndexer.GetValue(params dynamic?[]) and IIndexer.SetValue(dynamic?, params dynamic?[]) to generate run-time code for any indexer.
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.
ThisAttribute
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.Value to generate run-time code for any property.
Enums
AspectInitializationReason
There is no equivalent to this advice in Metalama because there is no concept of run-time aspect initialization.
CustomAttributeOverrideAction
In Metalama, use OverrideStrategy.
ImportMemberOrder
In Metalama, equivalent functionality can be achieved using InvokerOptions.
You can pass an InvokerOptions to the With
method of the member or invoker (e.g. IMethod.IMethod.With).
InterfaceOverrideAction
In Metalama, equivalent to OverrideStrategy.
MemberOverrideAction
In Metalama, equivalent to OverrideStrategy.
StateScope
No equivalent in Metalama.
Delegates
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 invokers (e.g. IEvent.IEvent.Add) 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.Value to generate run-time code for any property.
PropertyGetter<TValue, TIndex>
In PostSharp, this delegate allowed the run-time code of the aspect to access an indexer in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IIndexer.GetValue(params dynamic?[]) and IIndexer.SetValue(dynamic?, params dynamic?[]) to generate run-time code for any indexer.
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.Value to generate run-time code for any property.
PropertySetter<TValue, TIndex>
In PostSharp, this delegate allowed the run-time code of the aspect to access an indexer in the target code. In Metalama, no run-time helper is required because the template directly generates run-time code. Use IIndexer.GetValue(params dynamic?[]) and IIndexer.SetValue(dynamic?, params dynamic?[]) to generate run-time code for any indexer.