Watch, Follow, &
Connect with Us
Public Report
Report From:    [ Add a report in this area ]  
Report #:  8073   Status: Closed
Attributes visibility with class completion
Project:   Build #:  7.1.1523.17956
Version:    8.0 Submitted By:   Gerard Visent
Report Type:  Basic functionality failure Date Reported:  5/6/2004 6:30:52 AM
Severity:    Commonly encountered problem Last Updated: 6/7/2005 1:18:04 AM
Platform:    All platforms Internal Tracking #:  
Resolution: As Designed (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
When declaring a public or published property, and calling class completion, the getter and setter methods and the internal field are declared with the same visibility as the property.
This has been reported in QC#7003 and closed by Corbin Dunn.
However, the field should remain private to the class, otherwise it doesn't make sense to have getters, setters and properties.

Example:

TFoo =  class(TObject)
private
public
  FName : string; <--- This should be private
  procedure set_Name(const value: string);
public
  property Name: string read FName write set_Name;
end;
Steps to Reproduce:
Declare a new class, declare a new property in that class and press CTRL-SHIFT-C.
Workarounds
None
Attachment
None
Comments

Joe White at 5/6/2004 1:52:57 PM -
You mention attributes twice, but your sample code doesn't include any attributes at all. Did you mean to refer to fields?

Gerard Visent at 5/7/2004 6:45:39 AM -
Yes, sorry.  Has been corrected.

Jeremy North at 6/7/2005 1:16:08 AM -
As mentioned in the 7003 resolution. This is As Designed. Some .NET languages do not have properties and wouldn't then be able to call your code as you wished. If you do move the code to the private section the compiler creates methods for you which then means 2 function calls happen when you access your property.

Server Response from: ETNACODE01