Thursday, 23 February 2017

Strict Private Problem with Code Completion

Some time ago I noticed something annoying in Delphi XE with 'Strict Private' and code completion.

Here is an example:

TMyClass = class(TObject)
strict private

public
    property Test: string read FTest write FTest;
end;

When I do CTRL + Shift + C to add the private member to the class it does the following:

TMyClass = class(TObject)
strict private

private
    FTest: string;

published

public
    property Test: string read FTest write FTest;
end;

It adds FTest to the private section of the class and also adds the published section, which is not what I want, but if I remove 'strict' it does not add the 'published' section. Because of this I develop my classes  as 'private' and then once I have added all the require properties then I add 'strict' if required. I am not sure if this behaviour is some setting somewhere that I am not aware of, or whether this is something that might have changed in more recent versions of Delphi. Is there a valid reason to have a 'published' section when there is a 'strict private' section?

2 comments:

  1. The reason is that since the introduction of strict nobody told the code completion about it.

    It has been reported: https://quality.embarcadero.com/browse/RSP-10405

    ReplyDelete
  2. The bug has been around for some time and still has not been resolved. Looking at the created vs resolved chart and the last 30 day summary it looks like this bug will never be fixed. Looking at the 30 day summary, currently 191 issues have been created and only 2 resolved, with the 2 being resolved as duplicate of a new feature that has not been resolved. Bit worrying that nothing seems to be getting done.

    ReplyDelete