Although it is anattribute function included in the new
RTTI added in Delphi 2010, although there are differences depending on the version of Delphi, there are some predefined attributes in RTL.However, there is no proper description in these help for these predefined attributes. I tried to find out that ( I have not examined XE 6 / XE 7 because it is not available, but I think that there is not much difference between existing ones and XE 5I confirmed about Delphi XE 6 / XE 7 / XE 8/10 Seattle / 10.1 Berlin).
-
System
unitTCustomAttribute
- [2010..10.2 Tokyo] When newly defining the root class attribute of the custom attribute, derive it from TCustomAttribute
WeakAttribute [Weak]
- [XE 3 … 10.2 Tokyo] Indicates “weak” reference to prevent situations where ARC such as circular reference can not destroy objects
10 Seattle and earlier NEXTGEN compiler only Note: Compiler attributes – RAD Studio
Reference: weak reference (automatic reference count with Delphi mobile compiler) UnsafeAttribute [Unsafe]
- [XE 3 … 10.2 Tokyo] Prevent discard by ARC in situations where the reference count is 0, such as when generating objects
10 Seattle and earlier NEXTGEN compiler only Note: Compiler attributes – RAD Studio
Note: Unsafe attribute (automatic reference count in Delphi mobile compiler)
Reference: Delphi language for mobile development (white paper) RefAttribute [Ref]
- [XE 3 … 10.2 Tokyo] Forcibly pass constant parameters by reference According to help RefAttribute is a new feature of XE 4 , but actually it can also be used with XE 3 Reference: Compiler attribute – RAD Studio
Reference: Constant parameter (parameter (Delphi)) VolatileAttribute [Volatile]
- [XE4..10.2 Tokyo] Do not optimize for fields that may be rewritten by threads, such as copying values to registers or other temporary memory areas when generating code
10 Seattle and earlier NEXTGEN compiler only Note: Compiler attributes – RAD Studio
Note: New attributes of the Delphi compiler (new functions in Delphi XE 4 and C ++ Builder XE 4)
Reference: volatile (compiler attribute) StoredAttribute [Stored]
- [XE 7 .. 10.2 Tokyo] See System.Classes.StoredAttribute
HPPGENAttribute [HPPGEN]
- [XE8..10.2 Tokyo] Information used when generating hpp file for C ++ Builder, but it is unknown in details
HFAAttribute [HFA]
- [XE 8 .. 10.2 Tokyo]
It seems there is information on pageId = 86770118 (what it is) but details unknown (Override RTTI HFA information generated for record type / array type for ARM 64 platformFor internal use only.
with comment) AlignAttribute [Align]
- [10 Seattle … 10.2 Tokyo] It seems to specify the alignment of objects in memory, but with
For internal use only.
-
System.Classes
unitComponentPlatformsAttribute [ComponentPlatforms(<params>)]
- [XE2..10.2 Tokyo] To specify the platform (Word value) that specifies the platform on which the component operates, specify the logical sum of the following constants defined in System.Classes
pidWin32 [XE2..10.2 Tokyo]
pidWin64 [XE2..10.2 Tokyo]
pidOSX32 [XE2..10.2 Tokyo]
pidiOSSimulator [XE3..10.2 Tokyo]
pidAndroid [XE3..10.2 Tokyo]
pidLinux32 [XE3..10.2 Tokyo]
pidiOSDevice32 [XE8..10.2 Tokyo], pidiOSDevice [XE3..10.2 Tokyo]
pidLinux64 [XE8..10.2 Tokyo]
pidWinNX32 [XE3..10.2 Tokyo]
pidWinIoT32 [XE8..10.2 Tokyo]
(“Embedded IoT (Internet of Things) Windows w / Intel Galileo”)pidiOSDevice64 [XE8..10.2 Tokyo]
pidWinARM [10 Seattle..10.2 Tokyo]
pidOSX64 [10.1 Berlin..10.2 Tokyo], pidOSXNX64 [10.1 Berlin..10.2 Tokyo]
pidLinux32Arm [10.1 Berlin..10.2 Tokyo]
pidLinux64Arm [10.1 Berlin..10.2 Tokyo]
pidAndroid64 [10.1 Berlin..10.2 Tokyo]
TDefaultAttributeBase
- [XE 3 .. 10.2 Tokyo] DefaultAttribute / NoDefaultAttribute inherited from
DefaultAttribute [Default(<param>)]
- [XE 3 … 10.2 Tokyo] Property storage designator Parameters equivalent to default have default values (Boolean type, AnsiChar type, Char type, Integer type, Cardinal type, Int64 type, UInt 64 type, String type, Extended type One of them)
NoDefaultAttribute [NoDefault]
- [XE3..10.2 Tokyo] Property storage designator Equivalent designation for nodefault
StoredAttribute [Stored(<param>)]
- [XE3..XE7] Property storage Specify the name of a boolean value (False | True) or a storage handler (a method that returns a Boolean value without a Boolean property or parameter) for the specified parameter equivalent to stored (Moving to System unit after XE 8)
ObservableMemberAttribute [ObservableMember(<param>)]
- [XE3..10.2 Tokyo] In LiveBinding compliant component, specify the member name used by the LiveBinding component to generate expressions as parameters
-
System.JSON.Serializers
UnitJsonConverterAttribute [JsonConverter<param>]
- [10.2 Tokyo] Specifying the converter to be used with TJsonSerializer
JsonIgnoreAttribute [JsonIgnore]
- [10.2 Tokyo] Specifying members to ignore with TJsonSerializer
JsonNameAttribute [JsonName<param>]
- [10.2 Tokyo] Explicitly specify key names with TJsonSerializer
JsonInAttribute [JsonIn]
- [10.2 Tokyo] When TJsonMemberSerialization.In is specified as the parameter of the JsonSerialize attribute, it is targeted for serialization / deserialization by TJsonSerializer
JsonObjectHandlingAttribute [JsonObjectHandling<param>]
- [10.2 Tokyo] Specify handling of members of class type when deserializing with TJsonSerializer Specify one of the following values from the enumeration type TJsonObjectHandling
Auto [10.2 Tokyo]
Reuse [10.2 Tokyo]
Replace [10.2 Tokyo]
JsonObjectOwnership [JsonObjectOwnership<param>]
- [10.2 Tokyo] Specify handling of the original instance when class type member is generated when deserializing with TJsonSerializer Specify one of the following values from the enumeration type TJsonObjectOwnership
Auto [10.2 Tokyo]
Owned [10.2 Tokyo]
NotOwned [10.2 Tokyo]
JsonSerializeAttribute [JsonSerialize<param>]
- [10.2 Tokyo] Specify one of the following values from the enumeration type TJsonMemberSerialization as the specified parameter of the member to be serialized / deserialized by TJsonSerializer
Fields [10.2 Tokyo]
Public [10.2 Tokyo]
In [10.2 Tokyo]
-
Data.DBXJSONReflect
unit (replaced byREST.JsonReflect
unit in XE 5)JsonReflect [JsonReflect(<params>)]
- [XE..10.2 Tokyo] Parameters customizing the behavior when marshalling / unmarshalling objects in JSON format with TJSONMarshal / TJSONUnMarshal include the converter type, reverter type, interceptor type, population customizer type, marshaling Specify whether to automatically release generated intermediate objects
JSONBooleanAttribute
- [XE..10.2 Tokyo] JSONMarshalled / JSONOwned to inherit from
JSONMarshalled [JSONMarshalled(<param>)]
- [XE..10.2 Tokyo] The parameter (False | True) specifies whether the field and type are subject to marshalling / unmarshalling
JSONOwned [JSONOwned(<param>)]
- The parameter (False | True) specifies whether [XE..10.2 Tokyo] field is released when unmarshalling
-
Datasnap.DSAuth
unitTRoleAuth [TRoleAuth(<params>)]
- [XE..10.2 Tokyo] When authenticating with DataSnap, specify a list of authorized roles and a list of denied roles for parameters specifying roles that allow / deny access to server method classes and server methods Note: Roles (authentication and authorization)
-
REST.Json.Types
UnitJSONBooleanAttribute [JSONBoolean]
- [XE 6 .. 10.2 Tokyo] See Data.DBXJSONReflect.JSONBooleanAttribute
JSONMarshalledAttribute [JSONMarshalled]
- [XE 6 .. 10.2 Tokyo] See Data.DBXJSONReflect.JSONMarshalled
JSONOwnedAttribute [JSONOwned]
- [XE 6 .. 10.2 Tokyo] See Data.DBXJSONReflect.JSONOwned
JSONNameAttribute [JSONName]
- [XE 6 .. 10.2 Tokyo]
-
REST.JsonReflect
unitJsonReflect(XE5)/JsonReflectAttribute(XE6以降) [JsonReflect]
- [XE5..10.2 Tokyo] Refer to Data.DBXJSONReflect.JsonReflect (the class name is changed in XE 6)
JSONBooleanAttribute [JSONBoolean]
- [XE5] Refer to Data.DBXJSONReflect.JSONBooleanAttribute (Moved to REST.Json.Types unit after XE6)
JSONMarshalled [JSONMarshalled]
- [XE5] Refer to Data.DBXJSONReflect.JSONMarshalled (Moved to REST.Json.Types unit after XE 6)
JSONOwned [JSONOwned]
- [XE5] Refer to Data.DBXJSONReflect.JSONOwned (move to REST.Json.Types unit after XE 6)
-
EMS.ResourceType
unitResourceSuffixAttribute [ResourceSuffix]
- [XE 7 … 10.2 Tokyo] Specify the URL suffix with EMS Reference: EMS resource overview – RAD Studio
ResourceNameAttribute [ResourceName]
- [XE 7 … 10.2 Tokyo] Specifying Resource Names with EMS Reference: Overview of EMS Resources – RAD Studio
EndpointNameAttribute [EndpointName]
- [XE 7 … 10.2 Tokyo] Specify endpoint method name in EMS Reference: EMS resource overview – RAD Studio
TResourceCustomAttribute [TResourceCustom]
- [10.1 Berlin..10.2 Tokyo] EndPointRequestSummaryAttribute / EndPointRequestParameterAttribute / EndPointResponseDetailsAttribute / EndPointObjectsYAMLDefinitionsAttribute / EndPointObjectsJSONDefinitionsAttribute / AllowAnonymousTenantAttribute
EndPointRequestSummaryAttribute [EndPointRequestSummary]
- [10.1 Berlin..10.2 Tokyo] Generate method description on API document with EMS Note: Custom API document – RAD Studio
EndPointRequestParameterAttribute [EndPointRequestParameter]
- [10.1 Berlin..10.2 Tokyo] Generate a description of the parameters used in the request on the API document on the EMS Reference: Custom API document – RAD Studio
EndPointResponseDetailsAttribute [EndPointResponseDetails]
- [10.1 Berlin..10.2 Tokyo] Generate explanation of request response on API document with EMS Reference: Custom API document – RAD Studio
EndPointObjectsYAMLDefinitionsAttribute [EndPointObjectsYAMLDefinitions]
- [10.1 Berlin..10.2 Tokyo] Generate YAML version object definition on API document with EMS Note: Custom API document – RAD Studio
EndPointObjectsJSONDefinitionsAttribute [EndPointObjectsJSONDefinitions]
- [10.1 Berlin..10.2 Tokyo] Generate JSON version object definition on API document with EMS Reference: Custom API document – RAD Studio
AllowAnonymousTenantAttribute [AllowAnonymousTenant]
- [10.2 Tokyo] Skip Tenant Validation Procedure with EMS Reference: Sample RAD Server Multi-Tenant Application – RAD Studio
-
Macapi.ObjectiveC
unitMethodNameAttribute [MethodName]
- [XE4..10.2 Tokyo] For the Objective-C method defined in Delphi, specify the original method name on Objective-C
-
Androidapi.JNIBridge
unitJavaSignatureAttribute [JavaSignature]
- [XE5..10.2 Tokyo] Specify the original class name on Android for Android (JNI) class (interface) defined in Delphi
System.Win.WinRT
UnitWinRTClassNameAttribute [WinRTClassName]
- [10 Seattle … 10.2 Tokyo] Specify the original class name on WinRT for the interface of WinRT API defined in Delphi
Differences between versions of Delphi:
- In Delphi 2010 there are no predefined attributes used in the system.
- Delphi XE defines
TRoleAuth
in relation to DataSnap andJSON ...
for JSON reflection in DBX relation. - In Delphi XE 2,
ComponentPlatformsAttribute
was defined for multi platform support. WeakAttribute
/UnsafeAttribute
/RefAttribute
for ARC support in Delphi XE 3,TDefaultAttributeBase
/DefaultAttribute
/NoDefaultAttribute
/StoredAttribute
for migration from a future old RTTI to a new RTTI, andObservableMemberAttribute
for LiveBinding correspondence were respectively defined.- In Delphi XE 4,
MethodNameAttribute
was defined as iOS support. - In Delphi XE 5, since reflection of JSON was separated from DBX, JSON … of
Data.DBXJSONReflect
was redefined forREST.JsonReflect
, andJavaSignatureAttribute
was defined as Android correspondence. - In Delphi XE 6,
REST.JsonReflect.JsonReflect
was renamed toREST.JsonReflect.JsonReflectAttribute
and the definition ofJson ...
other thanJsonReflectAttribute
moved from theREST.JsonReflect
unit to theREST.Json.Types
unit. - In Delphi XE 7, the definition of
StoredAttribute
moved from theSystem.Classes
unit to theSystem
unit, andResourceSuffixAttribute
/ResourceNameAttribute
/EndpointNameAttribute
was defined for EMS. - In Delphi XE 8
HPPGENAttribute
andHFAAttribute
were defined. - In Delphi 10 Seattle
AlignAttribute
andWinRTClassNameAttribute
were defined. - In Delphi 10.1 Berlin, the
[weak]
[unsafe]
[volatile]
attribute is now supported by all compilers (NEXTGEN compiler only before 10 Seattle). We also definedTResourceCustomAttribute
/EndPointRequestSummaryAttribute
/EndPointRequestParameterAttribute
/EndPointResponseDetailsAttribute
/EndPointObjectsYAMLDefinitionsAttribute
/EndPointObjectsJSONDefinitionsAttribute
for custom API documents used in retrieving EMS API resources . - In Delphi 10.2 Tokyo,
System.JSON.Serializers
unit was added to defineJson ...
related to JSON serialization, andAllowAnonymousTenantAttribute
was defined for multi-tenant support of EMS. As for theSystem.JSON.Serializers
unit, since it is not officially documented at the present time (April 10, 2007), it is a change that seems not to be written in docwiki of Lyna ‘s Delphi 10.2 Tokyo. – Powerfully , how to useTJsonSerializer
. – Powerfully , see the practical example ofTJsonSerializer
– full power .
If you want to specify an attribute as a return value of a method like Unsafe attribute, add [Result: <attr>]
before the method declaration,
[Result: Unsafe]function Foo: TObject;
I will do as follows.
Results with following output