Namespace Metalama.Framework.Fabrics
This namespace allows you to add fabrics to your code. Like aspects, fabrics are executed at compile time. Unlike aspects, you do not need a custom attribute to add the fabric to your code. The only existence of the fabric in your code applies it to your code.
There are four kinds of fabrics. Each kind applies to a different scope. All fabric kinds can add aspects and validators within their scope. Type fabrics can additionally add advice to their scope, and project fabrics can set configuration options.
Kind | Base Class | Scope | Abilities |
---|---|---|---|
Type Fabrics | TypeFabric | The containing type (type fabrics are nested types) and any member. | Add aspects, advice, and validators. |
Namespace Fabrics | NamespaceFabric | Any type in the namespace that contains the fabric type. | Add aspects and validators. |
Project Fabrics | ProjectFabric | Any type in the project that contains the fabric type or in any project. | Add aspects and validators, and set configuration options. Project fabrics can be inherited from parent directories. |
Transitive Project Fabrics | TransitiveProjectFabric | Any type in any project referencing the containing project. | Add aspects and validators, and set configuration options. |
Note
For design-time performance and usability, it is highly recommended to implement type fabrics in a separate file, and mark the parent class as partial
.
Class diagrams
Fabrics
Amenders
Namespace member
Classes
Fabric
Allows adding aspects or analyzing a project, namespace, or type just by adding a type inheriting this class. You cannot inherit this class directly, inherit from ProjectFabric, NamespaceFabric, or TypeFabric instead.
NamespaceFabric
A class that, when inherited by a type in a given namespace, allows that type to analyze and add aspects to that namespace.
ProjectFabric
A class that, when inherited by a type in a project (under any name or namespace), allows that type to analyze and add aspects to that project.
TransitiveProjectFabric
A class that, when inherited by a type in an assembly (under any name or namespace), allows that type to analyze and add aspects to any project that references this assembly. However, the AmendProject(IProjectAmender) method is not executed in the current project (you will need another class that does not implement TransitiveProjectFabric to amend the current project).
TypeFabric
An class that, when inherited by a nested type in a given type, allows that nested type to analyze and add aspects to the parent type.
Interfaces
IAmender
IAmender<T>
Base interface for the argument of AmendProject(IProjectAmender), AmendNamespace(INamespaceAmender) or AmendType(ITypeAmender). Allows to report diagnostics and add aspects to the target declaration of the fabric.
IFabricInstance
Represents an instance of a Fabric type including its TargetDeclaration.
INamespaceAmender
Argument of AmendNamespace(INamespaceAmender). Allows reporting diagnostics and adding aspects to the target declaration of the fabric.
IProjectAmender
Argument of AmendProject(IProjectAmender). Allows reporting diagnostics and adding aspects to the target project.
ITypeAmender
Argument of AmendType(ITypeAmender). Allows reporting diagnostics and adding aspects to the target declaration of the fabric.