Why does Delphi complain about deprecating a setter method, but not other methods. I'm using XE3, and Delphi doesn't support deprecating a property, so I thought I would deprecate the setter method. But Delphi doesn't like that either. It is perfectly happy with the "Procedure Text;" as deprecated though???
Why does Delphi complain about deprecating a setter method, but not other methods. I'm using XE3, and Delphi doesn't support deprecating a property, so I thought I would deprecate the setter method. But Delphi doesn't like that either. It is perfectly happy with the "Procedure Text;" as deprecated though???
TtiIntegerListItem = class(TtiBaseObject)
private
FValue: Int64;
// fails to compile
procedure SetValue(const Value: Int64); deprecated 'The AValue property is deprecated. Please use the Value property instead.';
// this one is accepted though
procedure Text; deprecated 'use Value() instead';
public
constructor CreateCustom(AValue: Int64);
property AValue: Int64 Read FValue Write SetValue; // Delphi doesn't support deprecated here like FPC does.
property Value: Int64 Read FValue Write FValue;
end;
TtiIntegerListItem = class(TtiBaseObject)
private
FValue: Int64;
// fails to compile
procedure SetValue(const Value: Int64); deprecated 'The AValue property is deprecated. Please use the Value property instead.';
// this one is accepted though
procedure Text; deprecated 'use Value() instead';
public
constructor CreateCustom(AValue: Int64);
property AValue: Int64 Read FValue Write SetValue; // Delphi doesn't support deprecated here like FPC does.
property Value: Int64 Read FValue Write FValue;
end;
Graeme Geldenhuys no it doesn't, at least in Tokyo.
ReplyDeleteDoes same work in FPC mode Delphi??
Graeme Geldenhuys no, deprecated is not supported on properties. That's why I wrote this blog post: wiert.me - Functions over read-only properties: you cannot mark a property as deprecated in delphi – via Stack Overflow
ReplyDeleteUgochukwu Mmaduekwe wrote:
ReplyDelete> Does same work in FPC mode Delphi?
Yes, the 'deprecated' keyword works in all FPC compiler modes as far as I know. I explicitly test {$mode delphi} before I wrote this reply. The FPC compiler does give a warning about using a deprecated property.