Open sandboxFocus

Interface IAdviceFactory

Exposes all factory methods to create advice. Exposed on the Advice property of IAspectBuilder<TAspectTarget> or IAspectBuilder.

Namespace: Metalama.Framework.Advising
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IAdviceFactory

Properties

Name Description
MutableCompilation

Gets the mutable compilation that the current aspect builder is working on. It includes all modifications done by the current aspect in the current type using declarative advices and the IAdviceFactory.

Methods

Name Description
AddAnnotation<TDeclaration>(TDeclaration, IAnnotation<TDeclaration>, bool)

Adds a custom annotation to a declaration. An annotation is an arbitrary but serializable object that can then be retrieved using the GetAnnotations<TAnnotation>() method of the Enhancements<T>(T) object. Annotations are a way of communication between aspects or classes of aspects.

AddContract(IFieldOrPropertyOrIndexer, string, ContractDirection, object?, object?)

Adds a contract to a field, property or indexer. Contracts are usually used to validate the value assigned to fields properties or indexers or to normalize their value (null-to-empty, trimming, normalizing case, ...) before assignment. Alternatively, a contract can be used to validate the value returned by a property or indexer, in which case the direction parameter should be set to Output.

AddContract(IParameter, string, ContractDirection, object?, object?)

Adds a contract to a parameter. Contracts are usually used to validate parameters (pre- or post-conditions) or to normalize their value (null-to-empty, trimming, normalizing case, ...).

AddInitializer(IConstructor, IStatement)

Adds an initializer to a specific constructor by specifying an IStatement.

AddInitializer(IConstructor, string, object?, object?)

Adds an initializer to a specific constructor by using a template.

AddInitializer(INamedType, IStatement, InitializerKind)

Adds a type or instance initializer by specifying an IStatement.

AddInitializer(INamedType, string, InitializerKind, object?, object?)

Adds a type or instance initializer by using a template.

ImplementInterface(INamedType, INamedType, OverrideStrategy, object?)

Makes a type implement a new interface specified as an INamedType. Interface members can be introduced by marking an aspect member by InterfaceMemberAttribute, IntroduceAttribute(IDeclaration, IAttributeData, OverrideStrategy) or programmatically using Introduce methods.

ImplementInterface(INamedType, Type, OverrideStrategy, object?)

Makes a type implement a new interface specified as a reflection Type. Interface members can be introduced by marking an aspect member by InterfaceMemberAttribute, IntroduceAttribute(IDeclaration, IAttributeData, OverrideStrategy) or programmatically using Introduce methods.

IntroduceAttribute(IDeclaration, IAttributeData, OverrideStrategy)

Adds a custom attribute to a given declaration.

IntroduceAutomaticProperty(INamedType, string, IType, IntroductionScope, OverrideStrategy, Action<IPropertyBuilder>?, object?)

Introduces an auto-implemented property to the target type by specifying a property name and IType.

IntroduceAutomaticProperty(INamedType, string, Type, IntroductionScope, OverrideStrategy, Action<IPropertyBuilder>?, object?)

Introduces an auto-implemented property to the target type by specifying a property name and Type.

IntroduceBinaryOperator(INamedType, string, IType, IType, IType, OperatorKind, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
IntroduceClass(INamespaceOrNamedType, string, OverrideStrategy, Action<INamedTypeBuilder>?)
IntroduceConstructor(INamedType, string, OverrideStrategy, Action<IConstructorBuilder>?, object?, object?)
IntroduceConversionOperator(INamedType, string, IType, IType, bool, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
IntroduceEvent(INamedType, string, IntroductionScope, OverrideStrategy, Action<IEventBuilder>?, object?)

Introduces a new event to the target type, or overrides the implementation of an existing one, by specifying an event template.

IntroduceEvent(INamedType, string, string, string, string?, IntroductionScope, OverrideStrategy, Action<IEventBuilder>?, object?, object?)

Introduces a new event to the target type, or overrides the implementation of an existing one, by specifying individual template methods for the adder, the remover, and the raiser.

IntroduceField(INamedType, string, IntroductionScope, OverrideStrategy, Action<IFieldBuilder>?, object?)

Introduces a field to the target type by specifying a template.

IntroduceField(INamedType, string, IType, IntroductionScope, OverrideStrategy, Action<IFieldBuilder>?, object?)

Introduces a field to the target type by specifying a field name and IType.

IntroduceField(INamedType, string, Type, IntroductionScope, OverrideStrategy, Action<IFieldBuilder>?, object?)

Introduces a field to the target type by specifying a field name and Type.

IntroduceFinalizer(INamedType, string, OverrideStrategy, object?, object?)

Introduces a finalizer or overrides the implementation of the existing one.

IntroduceIndexer(INamedType, IType, string?, string?, IntroductionScope, OverrideStrategy, Action<IIndexerBuilder>?, object?, object?)

Introduces an indexer to the target type, or overrides the implementation of an existing one, by specifying individual template methods for each accessor.

IntroduceIndexer(INamedType, IReadOnlyList<(IType Type, string Name)>, string?, string?, IntroductionScope, OverrideStrategy, Action<IIndexerBuilder>?, object?, object?)

Introduces an indexer to the target type, or overrides the implementation of an existing one, by specifying individual template methods for each accessor.

IntroduceIndexer(INamedType, IReadOnlyList<(Type Type, string Name)>, string?, string?, IntroductionScope, OverrideStrategy, Action<IIndexerBuilder>?, object?, object?)

Introduces an indexer to the target type, or overrides the implementation of an existing one, by specifying individual template methods for each accessor.

IntroduceIndexer(INamedType, Type, string?, string?, IntroductionScope, OverrideStrategy, Action<IIndexerBuilder>?, object?, object?)

Introduces an indexer to the target type, or overrides the implementation of an existing one, by specifying individual template methods for each accessor.

IntroduceMethod(INamedType, string, IntroductionScope, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)

Introduces a new method or overrides the implementation of the existing one.

IntroduceParameter(IConstructor, string, IType, TypedConstant, Func<IParameter, IConstructor, PullAction>?, ImmutableArray<AttributeConstruction>)

Appends a parameter to a constructor by specifying its name and IType.

IntroduceParameter(IConstructor, string, Type, TypedConstant, Func<IParameter, IConstructor, PullAction>?, ImmutableArray<AttributeConstruction>)

Appends a parameter to a constructor by specifying its name and Type.

IntroduceProperty(INamedType, string, IntroductionScope, OverrideStrategy, Action<IPropertyBuilder>?, object?)

Introduces a property to the target type, or overrides the implementation of an existing one, by specifying a property template.

IntroduceProperty(INamedType, string, string?, string?, IntroductionScope, OverrideStrategy, Action<IPropertyBuilder>?, object?, object?)

Introduces a property to the target type, or overrides the implementation of an existing one, by specifying individual template methods for each accessor.

IntroduceUnaryOperator(INamedType, string, IType, IType, OperatorKind, OverrideStrategy, Action<IMethodBuilder>?, object?, object?)
Override(IConstructor, string, object?, object?)

Overrides the implementation of a constructor.

Override(IFieldOrProperty, string, object?)

Overrides a field or property by specifying a property template.

Override(IMethod, in MethodTemplateSelector, object?, object?)

Overrides the implementation of a method.

OverrideAccessors(IEvent, string?, string?, string?, object?, object?)

Overrides an event by specifying a template for the adder, the remover, and/or the raiser.

OverrideAccessors(IFieldOrProperty, in GetterTemplateSelector, string?, object?, object?)
OverrideAccessors(IFieldOrPropertyOrIndexer, in GetterTemplateSelector, string?, object?, object?)

Overrides a field or property by specifying a method template for the getter, the setter, or both.

OverrideAccessors(IIndexer, in GetterTemplateSelector, string?, object?, object?)
RemoveAttributes(IDeclaration, INamedType)

Removes all custom attributes of a given INamedType from a given declaration.

RemoveAttributes(IDeclaration, Type)

Removes all custom attributes of a given Type from a given declaration.

WithNamespace(INamespace, string)
WithTemplateProvider(ITemplateProvider)

Returns a copy of the current IAdviceFactory that will use the specified object to find template methods.

WithTemplateProvider(TemplateProvider)

Returns a copy of the current IAdviceFactory that will use the specified object to find template methods.

See Also