Context:
Classes ValueTypes Interfaces Delegates and Events Enums Fields Methods Constructors Properties Indexers Operators Iterators
*> Attribute on a class class-id Attributes attribute Author(name AuthorName = "Benjamin Franklin"). *> Attribute on a field 01 book string attribute Author(name AuthorName = "Benjamin Franklin"). *> Attribute on a property 01 bookProperty string property attribute Author(name AuthorName = "Benjamin Franklin"). *> Attribute on a method and argument method-id GetAnotherBook attribute Author(name AuthorName = "Benjamin Franklin") (arg1 as string attribute Author(name AuthorName = "Benjamin Franklin")) returning return-value as string. set return-value to book end method. end class. *> Attribute definition attribute-id AuthorAttribute public. 01 AuthorName string property. end attribute.
You can specify attributes using:
01 a binary-long attribute xml("UpperB").
attribute WebService(NAME Description="My service")
Attributes (also known as custom attributes) are used to provide additional information about elements within your program. Attributes may be used to describe methods, data items, properties, events, delegates, method parameters, assemblies, classes and method return values.
Much of the syntax used in a COBOL program describes program elements, such as the visibility of methods and fields (such as PUBLIC, PRIVATE and PROTECTED). All these descriptions are embedded as ‘Metadata’ into the dll or exe file output by the Compiler, and can be interrogated by other programs using Reflection. Attributes are a way of adding additional metadata to program elements in a way that is open ended and unlimited.
The attribute specified becomes part of the metadata describing the subject of the entry and is visible to a reflector.