This namespace enables the addition of fabrics to your code. Similar to aspects, fabrics are executed at compile time. However, unlike aspects, fabrics do not require a custom attribute for integration into your code. The mere existence of the fabric in your code applies it to your code.
There are four types of fabrics, each applying to a different scope. All types of fabrics can add aspects and validators within their respective scopes. Type fabrics have the additional capability of adding 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 enhanced design-time performance and usability, it is strongly recommended to implement type fabrics in a separate file and mark the parent class as partial.
Class diagrams
Fabrics
classDiagram
class Fabric {
}
class ProjectFabric {
AmendProject(IProjectAmender)
}
class TransitiveProjectFabric {
}
Fabric <|-- ProjectFabric : derives from
ProjectFabric <|-- TransitiveProjectFabric : derives from
class NamespaceFabric {
AmendNamespace(NamespaceAmender)
}
Fabric <|-- NamespaceFabric : derives from
class TypeFabric {
AmendType(TypeAmender)
}
Fabric <|-- TypeFabric : derives from
Amenders
classDiagram
class IAmender {
Project
}
class IDeclarationSelector {
With()
}
IDeclarationSelector <|-- IAmender : derives from
class IDeclarationSelection {
AddAspect()
AddAnnotation()
RegisterValidator()
RequireAspect()
}
IDeclarationSelection <-- IDeclarationSelector : creates
class IProjectAmender {
}
IAmender <|-- IProjectAmender
IAmender <|-- INamespaceAmender
IAmender <|-- ITypeAmender
class INamespaceAmender {
Namespace
}
class ITypeAmender {
Type
Advice : IAdviceFactory
}
IAdviceFactory <-- ITypeAmender : exposes
Namespace member
Classes
Fabric
Base class for compile-time entry points that execute within the compiler and IDE to add aspects, configure libraries, and implement architecture rules. This class cannot be inherited directly.
NamespaceFabric
A compile-time entry point that executes within the compiler and IDE to add aspects and implement architecture rules for a specific namespace and its nested namespaces.
ProjectFabric
A compile-time entry point that executes within the compiler and IDE to add aspects, configure libraries, and implement architecture rules for the current project.
QueryExtensions
Provides extension methods for IQuery<TDeclaration> to enable additional querying capabilities, such as selecting types by reflection, finding declarations with attributes, and selecting referenced assemblies.
TransitiveProjectFabric
A compile-time entry point that executes within the compiler and IDE to add aspects, configure libraries, and implement architecture rules for projects that reference the assembly containing this fabric. The fabric does not execute in the project where it is defined.
TypeFabric
A compile-time entry point implemented as a nested type that executes within the compiler and IDE to add aspects and implement transformations for its containing type.
Interfaces
IAmender
IAmender<T>
Base interface for the parameter passed to fabric methods such as AmendProject(IProjectAmender), AmendNamespace(INamespaceAmender), or AmendType(ITypeAmender). Provides capabilities to query declarations, add aspects programmatically, configure options, report diagnostics, and validate architecture.
IFabricInstance
Represents a Fabric as an IAspectPredecessor, allowing fabrics to participate in the aspect predecessor chain when they cause aspects to be added to declarations.
INamespaceAmender
The parameter passed to AmendNamespace(INamespaceAmender). Provides capabilities to query declarations within the namespace and its nested namespaces, add aspects programmatically using LINQ-like queries, configure options, report diagnostics, and validate architecture.
IProjectAmender
The parameter passed to AmendProject(IProjectAmender) (both for ProjectFabric and TransitiveProjectFabric). Provides capabilities to query declarations across the project, add aspects programmatically using LINQ-like queries, configure options, report diagnostics, and validate architecture.
IQuery
The non-generic base interface for IQuery<TDeclaration>. Represents a query over code declarations that can be used to programmatically select declarations and apply aspects, configuration, validators, and diagnostics. Provides LINQ-like methods that can be combined to create complex queries.
IQuery<TDeclaration>
Represents a LINQ-like query over a set of code declarations. Provides methods to filter, project, and transform the declaration set, and to apply aspects, validators, configuration, and diagnostics to the selected declarations.
ITaggedQuery<TDeclaration, TTag>
Represents a LINQ-like query over a set of code declarations where each declaration is associated with a tag. Create using WithTag<TTag>(Func<TDeclaration, TTag>). Tags allow you to pass additional data alongside declarations through query transformations, enabling context-aware aspect application and configuration.
ITypeAmender
The parameter passed to AmendType(ITypeAmender). Provides capabilities to query members of the containing type, add advice (such as overriding or introducing members), configure options, report diagnostics, and validate architecture.