Oxygene provides full support for Attributes and Aspects.

Attributes and Aspects are annotations that can be placed on pieces of code, from Types to Members, in order to affect compiler or runtime behavior.

Custom Attributes can be queried for at runtime using a technology called Reflection, while Aspects (some of which are provided by the system, but which can also be user-created) can affect and adjust code at compile-time.

The remainder of this text, and much of this documentation site, uses the term Aspects to refer to both Aspects and Attributes, for conciseness.

Aspects can be applied, where allowed, by enclosing one or more attribute names in square brackets:

  MyClass = public class

Multiple aspects can be applied using individual sets of brackets, or by separating the individual aspects with commas. Aspects can take optional parameters closed in parenthesis, including unnamed and named parameters.

  [Obfuscate(PublicMembers := true)]
  MyClass = public class

Scope Prefixes

By default, aspects apply to the code construct they immediately precede. In some cases, this is not possible, because the exact place where an aspect should be applied to has no direct code representation, or cannot easily accommodate an aspect. In these cases, the aspect can be prefixed with a scope modifier, followed by a colon:


The following scope prefixes are supported:

  • assembly: — applies the aspect to the entire assembly (i.e. the entire project)
  • module: — applies the aspect to the current Module, on .NET
  • global: — applies the aspect to the Global class
  • result: — applies the aspect to the result type of a Method or Property
  • param: — applies the aspect to a specific parameter of a Method or Indexer Property
  • var: — applies the aspect to the backing field of a Property or Event.
  • read: — apply the aspect to the backing read statement of a Property.
  • write: — apply the aspect to the backing write statement of a Property.

As well as:

  • aspect: — (optional/legacy) designates that the attribute is implemented via a Cirrus Aspect. Can be combined/prefixed with any of the previous prefixes.

See Also