Open sandboxFocusImprove this doc

Making aspects configurable

Complex and widely-used aspects often require a centralized, project-wide method for configuring their compile-time behavior. Implementing a configuration for aspects provides the following benefits:

  • Centralized aspect options: A configuration API allows the entire project, namespaces, or class families to be configured from a single location. Without a configuration API, users must supply the configuration each time a custom attribute is used.

  • Run-time performance: Considering compile-time options, your aspect can generate optimal run-time code, resulting in higher run-time performance of your application.

There are two complementary mechanisms for configuration: the configuration API and MSBuild properties.

Note

Compile-time configuration has significantly changed with Metalama 2023.4. If you are looking for the previous configuration API, see Exposing configuration (before v2023.4)

In this chapter

Article Description
Exposing a configuration API This article explains how to build a programmatic configuration API that can be called from fabrics.
Reading MSBuild properties This article describes how your aspect can consume an MSBuild property.
Customizing the change merging process This article explains in detail the options merging process, and how to customize it.