uid | level | summary |
---|---|---|
exposing-configuration-before-2023-4 |
300 |
The document provides instructions for establishing a configuration API prior to Metalama 2023.4, including constructing a class, overriding methods, and devising an extension method. |
Note
Starting with Metalama 2023.4, this approach is considered obsolete.
To establish a configuration API prior to Metalama 2023.4:
- Construct a class that inherits from xref:Metalama.Framework.Project.ProjectExtension and includes a default constructor.
- If necessary, override the xref:Metalama.Framework.Project.ProjectExtension.Initialize* method, which accepts the xref:Metalama.Framework.Project.IProject.
- In your aspect code, invoke the IProject.Extension<T>() method, where
T
represents your configuration class, to acquire the configuration object. - If desired, devise an extension method for the xref:Metalama.Framework.Project.IProject type to make your configuration API more discoverable. The class must be annotated with
[CompileTime]
. - For users to configure your aspect, they should implement a project fabric and access your configuration API using this extension method.
[!metalama-test ~/code/Metalama.Documentation.SampleCode.AspectFramework/AspectConfiguration.cs name="Consuming Property"]