Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Refactoring/Declare Field    [ Add a report in this area ]  
Report #:  58322   Status: Closed
Declare Field does not work if you have multiple classes/interfaces in a unit
Project:  Delphi Build #:  11.0.2902.10471
Version:    11.2 Submitted By:   Brian Kohrs
Report Type:  Basic functionality failure Date Reported:  2/15/2008 12:07:04 PM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   258005
Resolution: Fixed (Resolution Comments) Resolved in Build: : 11.0.2902.10471
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 13
Description
If you have multiple class/interfaces in a unit and try to declare a field in a class that is not the first one, Declare Field puts the field in the declaration of the first class/interface.
Steps to Reproduce:
1. Open the attached project.
2. In TFoo.Foo, use the Declare Field refactoring on the FField identifier.

Expected result:

unit Unit1;

interface

type
  IFoo = interface
  ['{D6528310-DB21-4ED4-8753-FC91E26D6271}']
  end;

  TFoo = class(TInterfacedObject, IFoo)
  strict private
    FField: Integer;
  public
    procedure Foo;
  end;

implementation

{ TFoo }

procedure TFoo.Foo;
begin
  FField := 1;
end;

end.

Actual result:

unit Unit1;

interface

type
  IFoo = interface
  ['{D6528310-DB21-4ED4-8753-FC91E26D6271}']

    FField: Integer;end;

  TFoo = class(TInterfacedObject, IFoo)
  public
    procedure Foo;
  end;

implementation

{ TFoo }

procedure TFoo.Foo;
begin
  FField := 1;
end;

end.
Workarounds
Declare the field manually.
Attachment
Project1.zip
Comments

None

Server Response from: ETNACODE01