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
[InternalImplement]
[CompileTime]
public interface IAdviceFactoryProperties
| Name | Description |
|---|---|
| Compilation | Gets the immutable ICompilation representing the code before any change done by the current aspect. |
| MutableCompilation | Gets the mutable ICompilation 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. |
| AddAspect(IDeclaration, IAspect) | |
| 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 |
| 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, InitializerPosition, object?, object?, IEnumerable<IField>?) | Adds a type or instance initializer by using a template, specifying whether the initializer should run before or after the call to the base initializer. |
| AddInitializer(INamedType, string, InitializerKind, object?, object?, IEnumerable<IField>?) | 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 |
| 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 |
| 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?) | Introduces a new binary operator or overrides the implementation of the existing one. |
| IntroduceClass(INamespaceOrNamedType, string, OverrideStrategy, Action<INamedTypeBuilder>?) | Introduces a new class to the target namespace or type. |
| IntroduceConstructor(INamedType, string, OverrideStrategy, Action<IConstructorBuilder>?, object?, object?) | Introduces a new constructor or overrides the implementation of the existing one. |
| IntroduceConversionOperator(INamedType, string, IType, IType, bool, bool, OverrideStrategy, Action<IMethodBuilder>?, object?, object?) | Introduces a new conversion operator or overrides the implementation of the existing one. |
| 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?, 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. |
| IntroduceExtensionBlock(INamedType, IType, string?, Action<IExtensionBlockBuilder>?) | Introduces a new extension block into a static class. Extension blocks allow adding extension members (methods, properties, operators) to a type (represented as an IType). Requires C# 14+ and Roslyn 5.0+. |
| IntroduceExtensionBlock(INamedType, Type, string?, Action<IExtensionBlockBuilder>?) | Introduces a new extension block into a static class. Extension blocks allow adding extension members (methods, properties, operators) to a type (represented as a Type). Requires C# 14+ and Roslyn 5.0+. |
| 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. |
| IntroduceInterface(INamespaceOrNamedType, string, OverrideStrategy, Action<INamedTypeBuilder>?) | Introduces a new interface to the target namespace or type. |
| 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, IPullStrategy?, ImmutableArray<AttributeConstruction>, IConstructorOverloadingStrategy?) | Appends a required parameter (i.e. one that has no default value) to a constructor by specifying its name and IType.
The framework also emits a forwarding constructor: a compile-time stub with the pre-mutation signature that chains
via |
| IntroduceParameter(IConstructor, string, IType, TypedConstant, IPullStrategy?, ImmutableArray<AttributeConstruction>) | Appends an optional parameter (i.e. one that has a compile-time-constant default value) to a constructor by specifying its name
and IType. The new parameter is added directly to the existing constructor; existing callers can omit the
argument, so source compatibility is preserved. Binary compatibility is not preserved. Because the constructor count
is unchanged, this overload is the right choice for dependency-injection scenarios where the container requires exactly one
applicable constructor (for example, |
| 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, IPullStrategy?, ImmutableArray<AttributeConstruction>, IConstructorOverloadingStrategy?) | Appends a required parameter (i.e. one that has no default value) to a constructor by specifying its name and Type.
The framework also emits a forwarding constructor: a compile-time stub with the pre-mutation signature that chains
via |
| IntroduceParameter(IConstructor, string, Type, TypedConstant, IPullStrategy?, ImmutableArray<AttributeConstruction>) | Appends an optional parameter (i.e. one that has a compile-time-constant default value) to a constructor by specifying its name
and Type. The new parameter is added directly to the existing constructor; existing callers can omit the
argument, so source compatibility is preserved. Binary compatibility is not preserved. Because the constructor count
is unchanged, this overload is the right choice for dependency-injection scenarios where the container requires exactly one
applicable constructor (for example, |
| 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?) | Introduces a new unary operator or overrides the implementation of the existing one. |
| 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?, 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?) | Overrides a field or property by specifying method templates for the getter, the setter, or both. |
| 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?) | Overrides an indexer by specifying method templates for the getter, the setter, or both. |
| 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. |
| RequireAspect(IDeclaration, Type) | |
| WithNamespace(INamespace, string) | |
| WithTemplateProvider(ITemplateProvider) | Returns a copy of the current IAdviceFactory that will use the specified object to find template methods. |
| WithTemplateProvider(in TemplateProvider) | Returns a copy of the current IAdviceFactory that will use the specified object to find template methods. |