Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 1.38 KB

File metadata and controls

26 lines (16 loc) · 1.38 KB
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.

Exposing configuration (before v2023.4)

Note

Starting with Metalama 2023.4, this approach is considered obsolete.

To establish a configuration API prior to Metalama 2023.4:

  1. Construct a class that inherits from xref:Metalama.Framework.Project.ProjectExtension and includes a default constructor.
  2. If necessary, override the xref:Metalama.Framework.Project.ProjectExtension.Initialize* method, which accepts the xref:Metalama.Framework.Project.IProject.
  3. In your aspect code, invoke the IProject.Extension<T>() method, where T represents your configuration class, to acquire the configuration object.
  4. 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].
  5. For users to configure your aspect, they should implement a project fabric and access your configuration API using this extension method.

Example

[!metalama-test ~/code/Metalama.Documentation.SampleCode.AspectFramework/AspectConfiguration.cs name="Consuming Property"]