Attribute Scopes
From RemObjects Software
This is a Oxygene Language Feature topic
Feel free to add your notes to this topic below.
By default, attributes found in code will be applied to the next code element following them - for example attributes might be placed in front of a type declaration, a method or a parameter.
In addition, the Oxygene compiler provides the following 3 scope prefixes that can be used to attach attributes to places that don't have a representation in code, such as the assembly itself:
Assembly Attributes
You may need to define attributes that apply at the assembly level and control information or behavior for the entire assembly (such as COM visibility, strong name or the assembly's title). The assembly prefix can be used to attach an attribute to the assembly:
[assembly:AssemblyTitle('test')]
Module Attributes
In theory, an assembly in .NET is a collection of one or more modules. For Oxygene, as for most other .NET languages including C#, there is a one-to-one mapping between assembly and module, but some .NET compilers support multiple modules per assembly.
Still, module attribute scope is supported, because some system attributes are defined to only be applicable at the module level. For example:
[module: Debuggable(True, true)]
Global Attributes
Finally, the global scope allows you to apply attributes to the Global Class that contains global methods and variables defined in your project (if globals are enabled in your project settings).
[global: MyAttribute]
Read/Write Attributes
The read: and write: scopes can be used when the attributes are defined just before a property, to apply attributes on the getter and setter of a property.
See Also
Product: RemObjects Oxygene (formerly known as Chrome)
Current version: 3.0
Previous Versions: 'Joyride' (2.0), 'Floorshow' (1.5), 'Adrenochrome' (1.0)
Glossary — Keywords — Language Features — Platform Features — Samples — Articles — How To — Issues
Categories: Text | Oxygene | Language | Feature
