This attribute feature is included in the new
RTTI added in Delphi 2010, but there are some attributes that are predefined in RTL, although there are differences depending on the Delphi version. However, there is no descriptive description of these predefined attributes in the help. So I examined it (I have not checked out XE6 / XE7 because I do not have it at hand, but I don’t think there is any difference between XE5 and existing one(I also checked Delphi XE6 / XE7 / XE8 / 10 Seattle / 10.1 Berlin).
-
System
unitTCustomAttribute
- [2010..10.3 Rio] Root class of custom attribute To
define a new attribute, derive from TCustomAttribute WeakAttribute [Weak]
- [XE3..10.3 Rio] Indicates a “weak” reference that prevents situations where ARC cannot destroy objects such as circular references
10 Seattle and earlier NEXTGEN compiler only
Reference: Compiler attributes-RAD Studio
reference : Weak references (automatic reference counting with Delphi mobile compiler) UnsafeAttribute [Unsafe]
- [XE3..10.3 Rio] Prevents ARC destruction when the reference count is 0, such as when an object is created
10 Seattle and earlier NEXTGEN compiler only
Reference: Compiler attributes-RAD Studio
Reference: Unsafe attribute (Delphi Mobile (Automatic reference counting by the compiler)
Reference: Delphi language for mobile development (white paper) RefAttribute [Ref]
- [XE3..10.3 Rio] Force constant parameter to pass by reference
According to help, RefAttribute is a new feature of XE4 , but it can actually be used in XE3.
Reference: Compiler attribute-RAD Studio
Reference: Constant parameter (Parameter ( Delphi)) VolatileAttribute [Volatile]
- [XE4..10.3 Rio] Do not perform optimizations that copy values to registers or other temporary memory areas during code generation for fields that may be rewritten by threads
10 Seattle and earlier NEXTGEN compiler only
Reference: Compiler attributes-RAD Studio
Reference: Delphi compiler new attributes (new in Delphi XE4 and C ++ Builder XE4)
Reference: volatile (compiler attribute) StoredAttribute [Stored]
- [XE7..10.3 Rio] See System.Classes.StoredAttribute
HPPGENAttribute [HPPGEN]
- [XE8..10.3 Rio] It seems to be information used when generating hpp file for C ++ Builder, but details are unknown
HFAAttribute [HFA]
- [XE8..10.3 Rio]
There seems to be information on pageId = 86770118 (what it), but details are unknown ( commented withOverride RTTI HFA information generated for record / array types for ARM64 platformsFor internal use only.
) AlignAttribute [Align]
- [10 Seattle..10.3 Rio] It seems to specify the alignment of objects in memory, but there is a comment ,
For internal use only.
-
System.Classes
unitComponentPlatformsAttribute [ComponentPlatforms(<params>)]
- [XE2..10.3 Rio] Specify the platform on which the component operates. Specify
the logical sum of the following constants defined in System.Classes for the parameter (Word value).pidWin32 [XE2..10.3 Rio]
pidWin64 [XE2..10.3 Rio]
pidOSX32 [XE2..10.3 Rio]
pidiOSSimulator32 [10.3 Rio], pidiOSSimulator [XE3..10.3 Rio]
pidAndroid32Arm [10.3 Rio], pidAndroid [XE3..10.3 Rio]
pidLinux32 [XE3..10.3 Rio]
pidiOSDevice32 [XE8..10.3 Rio], pidiOSDevice [XE3..10.3 Rio]
pidLinux64 [XE8..10.3 Rio]
pidWinNX32 [XE3..10.3 Rio]
pidWinIoT32 [XE8..10.3 Rio]
(“Embedded IoT (Internet of Things) Windows w / Intel Galileo”)pidiOSDevice64 [XE8..10.3 Rio]
pidWinARM32 [10.3 Rio], pidWinARM [10 Seattle..10.2 Tokyo]
pidOSX64 [10.1 Berlin..10.3 Rio], pidOSXNX64 [10.1 Berlin..10.2 Tokyo]
pidLinux32Arm [10.1 Berlin..10.3 Rio]
pidLinux64Arm [10.1 Berlin..10.3 Rio]
pidAndroid64Arm [10.3 Rio], pidAndroid64 [10.1 Berlin..10.2 Tokyo]
pidiOSSimulator64 [10.3 Rio]
TDefaultAttributeBase
- [XE3..10.3 Rio] DefaultAttribute / NoDefaultAttribute inheritance source
DefaultAttribute [Default(<param>)]
- [XE3..10.3 Rio] The property storage specifier default is equivalent
to the default value (Boolean type, AnsiChar type, Char type, Integer type, Cardinal type, Int64 type, UInt64 type, String type, Extended type) Any) NoDefaultAttribute [NoDefault]
- [XE3..10.3 Rio] Property storage specifier equivalent to nodefault
StoredAttribute [Stored(<param>)]
- [XE3..XE7] Specify the name of a boolean value (False | True) or storage handler (a method that returns a Boolean value without a Boolean property or parameter) for the specified parameter equivalent to the property storage specifier stored
(Move to System unit after XE8) ObservableMemberAttribute [ObservableMember(<param>)]
- [XE3..10.3 Rio] In LiveBindings compatible component, specify the member name used by LiveBindings component when generating an expression as a parameter
-
System.JSON.Serializers
unitJsonConverterAttribute[JsonConverter<param>]
- [10.3 Rio] Specifying the converter used by TJsonSerializer
JsonIgnoreAttribute[JsonIgnore]
- [10.3 Rio] Specifying members to be ignored by TJsonSerializer
JsonNameAttribute[JsonName<param>]
- [10.3 Rio] Explicitly specify key name in TJsonSerializer
JsonInAttribute[JsonIn]
- [10.3 Rio] When TJsonMemberSerialization.In is specified in the parameter of JsonSerialize attribute, it is serialized / deserialized with TJsonSerializer
JsonObjectHandlingAttribute[JsonObjectHandling<param>]
- [10.3 Rio] Specify handling of class type members when deserializing with
TJsonSerializer Specify one of the following values from enumeration type TJsonObjectHandling as a parameterAuto [10.2 Tokyo..10.3 Rio]
Reuse [10.2 Tokyo..10.3 Rio]
Replace [10.2 Tokyo..10.3 Rio]
JsonObjectOwnership[JsonObjectOwnership<param>]
- [10.3 Rio] Specify handling of original instance when class type member is generated when deserializing with
TJsonSerializer Specify one of the following values from enumeration type TJsonObjectOwnership for parameterAuto [10.2 Tokyo..10.3 Rio]
Owned [10.2 Tokyo..10.3 Rio]
NotOwned [10.2 Tokyo..10.3 Rio]
JsonSerializeAttribute[JsonSerialize<param>]
- [10.2 Tokyo..10.3 Rio] Specifying the member to be serialized / deserialized with
TJsonSerializer Specify one of the following values from enumeration type TJsonMemberSerialization for the parameterFields [10.2 Tokyo..10.3 Rio]
Public [10.2 Tokyo..10.3 Rio]
In [10.2 Tokyo..10.3 Rio]
-
Data.DBXJSONReflect
Unit (REST.JsonReflect
replaced with unit in XE5 )JsonReflect [JsonReflect(<params>)]
- [XE..10.3 Rio] TJSONMarshal / TJSONUnMarshal
parameters for customizing the behavior when marshalling / unmarshalling objects in JSON format include converter type, reverter type, interceptor type, population customizer type, marshalling Specifies whether to automatically release generated intermediate objects JSONBooleanAttribute
- [XE..10.3 Rio] Inheritance of JSONMarshalled / JSONOwned
JSONMarshalled [JSONMarshalled(<param>)]
- [XE..10.3 Rio] Use parameter (False | True) to specify whether the field or type is subject to marshalling / unmarshalling
JSONOwned [JSONOwned(<param>)]
- [XE..10.3 Rio] Specify with parameter (False | True) whether to release the field during unmarshalling
-
Datasnap.DSAuth
unitTRoleAuth [TRoleAuth(<params>)]
- [XE..10.3 Rio] When authenticating with DataSnap, specify the role to allow / deny access to the server method class and server method Specify
the list of allowed roles and the list of denied roles as parameters
Reference: Role (authentication and authorization)
-
REST.Json.Types
unitJSONBooleanAttribute [JSONBoolean]
- [XE6..10.3 Rio] See Data.DBXJSONReflect.JSONBooleanAttribute
JSONMarshalledAttribute [JSONMarshalled]
- [XE6..10.3 Rio] See Data.DBXJSONReflect.JSONMarshalled
JSONOwnedAttribute [JSONOwned]
- [XE6..10.3 Rio] See Data.DBXJSONReflect.JSONOwned
JSONNameAttribute [JSONName]
- [XE6..10.3 Rio]
-
REST.JsonReflect
unitJsonReflect(XE5)/JsonReflectAttribute(XE6以降) [JsonReflect]
- [XE5..10.3 Rio] Refer to Data.DBXJSONReflect.JsonReflect (class name changed in XE6)
JSONBooleanAttribute [JSONBoolean]
- [XE5] Refer to Data.DBXJSONReflect.JSONBooleanAttribute (Move to REST.Json.Types unit after XE6)
JSONMarshalled [JSONMarshalled]
- [XE5] Refer to Data.DBXJSONReflect.JSONMarshalled (Move to REST.Json.Types unit after XE6)
JSONOwned [JSONOwned]
- [XE5] Refer to Data.DBXJSONReflect.JSONOwned (Move to REST.Json.Types unit after XE6)
-
EMS.ResourceType
unitTResourceCustomAttribute [TResourceCustom]
- [10.1 Berlin..10.3 Rio] EndPointRequestSummaryAttribute (10.1 Berlin..10.2 Tokyo) / EndPointRequestParameterAttribute (10.1 Berlin..10.2 Tokyo) / EndPointResponseDetailsAttribute (10.1 Berlin..10.2 Tokyo) / EndPointObjectsYAMLDefinitionsAttribute (10.1 Berlin..10.2 Tokyo) / EndPointObjectsJSONDefinitionsAttribute ( 10.1 Berlin..10.3 Rio) / AllowAnonymousTenantAttribute (10.1 Berlin..10.2 Tokyo) / ResourceNameAttribute (10.3 Rio) / EndPointObjectsYAMLDefinitionsAttribute (10.3 Rio)
TEndpointCustomAttribute [TEndpointCustom]
- [10.3 Rio] ResourceSuffixAttribute / EndpointNameAttribute / EndPointRequestSummaryAttribute / EndPointRequestParameterAttribute / EndPointResponseDetailsAttribute / AllowAnonymousTenantAttribute / EndPointProduceAttribute / EndPointMethodAttribute inheritance source
ResourceSuffixAttribute [ResourceSuffix]
- [XE7..10.3 Rio] Specify URL suffix with EMS
Reference: Overview of EMS resources-RAD Studio ResourceNameAttribute [ResourceName]
- [XE7..10.3 Rio] Specify resource name in EMS
Reference: EMS Resource Overview-RAD Studio EndpointNameAttribute [EndpointName]
- [XE7..10.3 Rio] Specify endpoint method name in EMS
Reference: Overview of EMS resources-RAD Studio EndPointRequestSummaryAttribute [EndPointRequestSummary]
- [10.1 Berlin..10.3 Rio] Generate method description on API document with EMS
Reference: Custom API document-RAD Studio EndPointRequestParameterAttribute [EndPointRequestParameter]
- [10.1 Berlin..10.3 Rio] Generate description of parameters used in request in EMS on API document
Reference: Custom API document-RAD Studio EndPointResponseDetailsAttribute [EndPointResponseDetails]
- [10.1 Berlin..10.3 Rio] Generate request response description on API document with EMS
Reference: Custom API document-RAD Studio EndPointObjectsYAMLDefinitionsAttribute [EndPointObjectsYAMLDefinitions]
- [10.1 Berlin..10.3 Rio] Generate YAML version object definition on API document with EMS
Reference: Custom API document-RAD Studio EndPointObjectsJSONDefinitionsAttribute [EndPointObjectsJSONDefinitions]
- [10.1 Berlin..10.3 Rio] Generate JSON object definition on API document with EMS
Reference: Custom API document-RAD Studio AllowAnonymousTenantAttribute [AllowAnonymousTenant]
- [10.2 Tokyo..10.3 Rio] Skip the tenant verification procedure in EMS
Reference: Sample RAD server Multi-tenant application-RAD Studio EndPointProduceAttribute
- [10.3 Rio]
Reference: RAD Server extension URL mapping-RAD Studio EndPointConsumeAttribute
- [10.3 Rio]
Reference: RAD Server extension URL mapping-RAD Studio
-
Macapi.ObjectiveC
unitMethodNameAttribute [MethodName]
- [XE4..10.3 Rio] Specify the original method name on Objective-C for Objective-C method defined in Delphi
-
Androidapi.JNIBridge
unitJavaSignatureAttribute [JavaSignature]
- [XE5..10.3 Rio] Specify the original class name on Android for Android (JNI) class (interface) defined in Delphi
System.Win.WinRT
unitWinRTClassNameAttribute [WinRTClassName]
- [10 Seattle..10.3 Rio] Specify the original class name on WinRT for the WinRT API interface defined in Delphi
Differences between Delphi versions:
- In Delphi 2010 there are no predefined attributes to use in the system.
- Delphi XE defined TRoleAuth for DataSnap and JSON … for JSON reflection for DBX.
- Delphi XE2 defines ComponentPlatformsAttribute for multi-platform support.
- Delphi XE3 defined WeakAttribute / UnsafeAttribute / RefAttribute for ARC, possibly TDefaultAttributeBase / DefaultAttribute / NoDefaultAttribute / StoredAttribute for the transition from the old RTTI to the new RTTI, and ObservableMemberAttribute for LiveBinding.
- In Delphi XE4, MethodNameAttribute is defined for iOS.
- In Delphi XE5, JSON reflection is separated from DBX, so Data.DBXJSONReflect’s JSON … is redefined in REST.JsonReflect, and JavaSignatureAttribute is defined for Android.
- In Delphi XE6, the class name of REST.JsonReflect.JsonReflect has been changed to REST.JsonReflect.JsonReflectAttribute, and the definition of Json … other than JsonReflectAttribute has been moved from the REST.JsonReflect unit to the REST.Json.Types unit.
- Delphi XE7 moved the StoredAttribute definition from the System.Classes unit to the System unit, and defined ResourceSuffixAttribute / ResourceNameAttribute / EndpointNameAttribute for EMS.
- Delphi XE8 defined HPPGENAttribute and HFAAttribute.
- In Delphi 10 Seattle, AlignAttribute and WinRTClassNameAttribute were defined.
- Delphi 10.1 Berlin now supports the [weak] [unsafe] [volatile] attribute for all compilers (only NEXTGEN compiler before 10 Seattle). In addition , TResourceCustomAttribute / EndPointRequestSummaryAttribute / EndPointRequestParameterAttribute / EndPointResponseDetailsAttribute / EndPointObjectsYAMLDefinitionsAttribute / EndPointObjectsJSONDefinitionsAttribute for custom API document used for EMS API resource acquisition was defined.
- In Delphi 10.2 Tokyo, the System.JSON.Serializers unit was added to define JSON serialization-related Json …, and AllowAnonymousTenantAttribute was defined to support EMS multi-tenancy. The System.JSON.Serializers unit is not officially documented at the moment (2017/04/10), so changes that are unlikely to be written in Lyna ‘s Delphi 10.2 Tokyo docwiki. – Zenryokuwawa , use of TJsonSerializer. – Zenryokuwawa , practical examples of TJsonSerializer – Zenryokuwawa See the per.
- In Delphi 10.3 Rio, the inheritance relationship of attribute classes on the EMS.ResourceTypes unit has been rearranged.
If you want to specify an attribute for the return value of a method, such as the Unsafe attribute, [Result: <attr>]
add a prefix before the method declaration ,
[Result: Unsafe]function Foo: TObject;
Like this.
2015/06/19 update: Added information about Delphi XE6 / XE7 / XE8.
2015/10/05 update: Added information about Delphi 10 Seattle.
2016/05/02 postscript: Added information about Delphi 10.1 Berlin.
2017/04/10 postscript: Added information about Delphi 10.2 Tokyo. I quoted a lot from Lyna . Thank you very much.
2019/03/07 update: Added information about Delphi 10.3 Rio.
Leave a comment