On 12/07/2019 11:09 pm, Sven Barth via fpc-pascal wrote: > type > TMyAttribute = class(TCustomAttribute) > constructor Create; > constructor Create(aArg: String); > constructor Create(aArg: TGUID); > constructor Create(aArg: LongInt); > end; > > {$M+} > [TMyAttribute] > TTestClass = class > private > fTest: LongInt; > published > [TMyAttribute('Test')] > property Test: LongInt read fTest; > end;
Nothing to do with the actual implementation of Custom Attributes, but rather about using it. I know attributes are TCustomAttribute descendants, but for the sake of code readability, my personal opinion would be to NOT name custom attributes with the 'T' prefix like is normally done in Object Pascal. A visual comparison. So imagine a RESTful class could be decorated as follows: [Path('/troopers')] [Produces('application/json')] TStormtrooperResource = class(TObject) published [Path('/{id}')] [GET] function GetStormtrooper([PathParam('id')] id: string): TStormtrooper; [POST] function CreateTrooper(trooper: TStormTrooper): TStormtrooper; end; ... instead of the traditional Object Pascal naming conversion.... [TPath('/troopers')] [TProduces('application/json')] TStormtrooperResource = class(TObject) published [TPath('/{id}')] [TGET] function GetStormtrooper([TPathParam('id')] id: string): TStormtrooper; [TPOST] function CreateTrooper(trooper: TStormTrooper): TStormtrooper; end; Just my observation..... Your mileage may vary. ;-) Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal