Attributes (.NET)

Attributes enable you to provide descriptive or behavioral information about your code. All attributes are classes that inherit from System.Attribute. Attributes immediately precede the member they are decorating and have the following syntax:

{attribute[(value_list)]} 

attribute

The name of an attribute that inherits from the System.Attribute class with AttributeTargets of either All or one of the specific targets listed in the table below.

value_list

(optional) One or more values for the attribute, separated by commas. The types passed as values must either match the parameters of the constructor of the attribute or use the property names of the attribute class.

Note

You cannot mix these two types of values in the same attribute call. For example, the following is invalid:

{MyAttribute(value1,name=value2)}

The following members can have attributes:

Members and their available attributes

Member

AttributeTargets (in addition to All)

Class

Class

Class field

Field

Constructor

Constructor

Delegate

Delegate

Enumeration

Enum

Event

Event

Function

Method

Interface

Interface

Method

Method

Parameter

Parameter

Property

Property

Structure

Struct

Subroutine

Method

Record

The return type for a method or function can also have an attribute. A return type attribute has the following syntax:

{returntype: attribute[(value_list)]}

AttributeTargets must be All or ReturnValue.

Assembly attributes

Assembly attributes enable you to set file properties on Synergy assemblies. An assembly attribute has the following syntax:

{assembly: attribute[(value_list)]}

attribute

The name of an attribute that inherits from the .NET System.Attribute class with AttributeTargets of All or Attribute.

value_list

(optional) One or more values for the attribute, separated by commas. The types passed as values must match the parameters of the constructor of the attribute.

Below is a list of common assembly attributes from System.Reflection:

For example,

{assembly: AssemblyTitle("My Title")}
{assembly: AssemblyDescription("My Description")}

The Synergy .NET compiler can compile a source file that contains only assembly attributes

Note

Two xfServerPlus attributes, xfMethod and xfParameter, are also available for subroutines, functions, and parameters of subroutines and functions. These attributes have a specific, limited function, and are not supported in Synergy .NET. See Using attributes to define Synergy methods.