Special Attributes
From RemObjects Software
In addition to normal Custom Attributes, the Oxygene compiler provides support for the following attribute classes, resulting in specific code or data generated in the output assembly:
| | |
|---|---|
| AssemblyKeyFileAttribute AssemblyKeyNameAttribute |
These attributes control strong-naming and signing of the assembly, as required for installation in the Global Assembly Cache (GAC). |
| AssemblyVersionAttribute AssemblyFileVersionAttribute | These two attributes specify the version numbering of the output assembly.
If AssemblyFileVersionAttribute is not specified, the AssemblyVersionAttribute value is used for both the string name and the Win32 file version. If it is specified, the AssemblyFileVersion will be for the Win32 version resoirce and the AssemblyVersion will go into the strong name. |
| AssemblyCompanyAttribute AssemblyProductAttribute AssemblyCopyrightAttribute AssemblyTrademarkAttribute |
These attributes contribute additional fields to the assembly strong name and or version information |
| OutAttribute | Used to mark out params. The .NET runtime passes out parameters by passing them as "by reference" ( var) and setting the out modifier on the parameter. |
| ComImportAttribute InAttribute OptionalAttribute MarshalAsAttribute NonSerializableAttribute SerializableAttribute | These are not real custom attributes, but represent flags in the IL. Oxygene knows about these and correctly maps them to the underlying flags. |
| DllImportAttribute | DllImport is used to import functions from unmanaged dlls (such as Win32 dlls or shared objects under Linux/Mono). A static method header can be defined in a class, and the DllImport attribute can be added to specify what dll and what function to import (and possibly more details of how to marshal parameters back and forth) and calls to this method will be directed to the external Win32 dll. See DllImportAttribute for more information. |
| ConditionalAttribute | This attribute is used to mark types or members for conditional compilation.
The compiler will link calls to members with this attribute only if the matching define is set. For example, most methods in RemObjects.DebugServer.dll have the [Conditional('DebugServer')] attribute. This means that if you write code referencing this assembly and use those methods, the actual calls will only be generated if the "DebugServer" define is set for the project or via $IFDEF. The nice thing about ConditionalAttribute is that it not only works within the same assembly as traditional IFDEFs, but also across assembly boundaries. The DebugServer assembly, for example, is written in C# and completely outside of the control of the oxygene compiler - yet the oxygene-written code will behave differently depending on what defines with which it will be compiled. |
| ObsoleteAttribute | This attribute marks types or members (or entire assemblies) as obsolete. When the compiler notices that you are using an item marked with this attribute, it will generate the appropriate warning or error (depending on the parameters supplied to the attribute. |
| StructLayout | See Records for modifying record storage layouts. |
| GuidAttribute | The compiler will enforce proper GUID format for string constants used with the GuidAttribute. |
| DebuggableAttribute | The compiler will emit this assembly level attribute automatically when compiling, however when it's present, the compiler will use the one defined in code. |
| MethodImplAttributes | an attribute that changes the flags of a MethodDef in the metadata. Used for ComImport and internal calls. Generally these shouldn't be used as they might create invalid code, depending on the combination of flags. |
| Security Attributes |
Oxygene provides full support for understanding security attributes and generating the appropriate XML structures inside the output assembly. |
| CoClassAttribute |
This attribute is used in COM imports to define what class is a co-class for the interface this is applied to. When it's defined, the new operator works on interfaces and it will instantiate the proper co-class. |
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
