MetalamaAPI documentationAspect APIMetalama.​Framework.​OptionsIHierarchical­Options
Open sandboxFocus

IHierarchicalOptions Interface

Base interface for hierarchical options. Hierarchical options are options exposed and consumed by aspects and fabrics. Users can typically set options at different levels of the code level: for the whole project, for a namespace, for a type, or for a member, as decided by the aspect author.

Namespace: Metalama.Framework.Options
Assembly: Metalama.Framework.dll
public interface IHierarchicalOptions : IIncrementalObject, ICompileTimeSerializable

Users typically set options from a fabric using the SetOptions<TOptions>(TOptions) method of the Outbound object.

Implementations of this class must be immutable. An instance of this object represents a layer of options, and these layers are merged by the ApplyChanges(Object, in ApplyChangesContext) method. Therefore, all properties should typically be nullable or support another representation of being unset.

Classes that implement this interface must implement the IHierarchicalOptions<T> generic interface where T is the type of declarations for which the user is allowed to set the options. Typically, a single class would implement several instances of this instance. For instance, for an option affecting a method-level aspect, a good practice is to implement this interface for ICompilation, INamespace, INamedType and IMethod.

Classes that implement this interface can be annotated with the HierarchicalOptionsAttribute custom attribute, which allows authors to customize the inheritance mechanisms of the option.

Attribute classes and aspect classes can implement the IHierarchicalOptionsProvider interface if they want to contribute options.

Options are exposed by the declaration.Enhancements<T>(T).GetOptions<TOptions>() method.


Name Description

Gets the default options from the current project.

Extension Methods

IncrementalObjectExtensions.ApplyChangesSafe<T>(T, T, in ApplyChangesContext)
IncrementalObjectExtensions.ApplyChanges<T>(T, T, in ApplyChangesContext)

See Also