Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Class Explorer    [ Add a report in this area ]  
Report #:  81729   Status: Closed
Error in Class Explorer when using existing methods to implement a property
Project:  C++Builder Build #:  14.0.3593.25826
Version:    14.0 Submitted By:   Peter Hull
Report Type:  Basic functionality failure Date Reported:  2/2/2010 4:37:50 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   274798
Resolution: Fixed (Resolution Comments) Resolved in Build: :
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
When adding a property there is an option to use existing methods for its implementation. This option gives a confusing/irrelevant error message and generates code that won't compile.
Steps to Reproduce:
1. Start with a class defined like this
class TTester {

private:

void SetValue(int);

int GetValue();
};

2. Use Class Explorer to add a property, Name= Value, Type= int, Visibility= public, and select Existing Field/Method = GetValue() for Read and Existing Field/Method= SetValue(int) for Write

3. Press Add

4. See error message 'GetValue() is not a valid identifier. Root filenames of IDE-managed units must be valid identifiers.'

Generated code is wrong and won't compile:
class TTester {

private:


void SetValue(int);

int GetValue();
public:

__property int Value = {read=GetValue(), write=SetValue(int)};
};
Should be
class TTester {

private:


void SetValue(int);

int GetValue();
public:

__property int Value = {read=GetValue, write=SetValue};
};
Workarounds
None
Attachment
None
Comments

Peter Hull at 2/3/2010 2:30:54 AM -
This also doesn't work if a property is based on an existing field, for example, basing a property 'Value' on field 'FValue' in this class:
class TTester
{

private:

int FValue;
};
becomes
class TTester
{

private:

void __fastcall FValue(int val);

int __fastcall FValue();

int FValue;
public:

__property int Value = {read=FValue, write=FValue};
};
i.e. it erroneously adds in method signatures for 'FValue'

Tomohiro Takahashi at 2/3/2010 6:32:15 PM -
Thanks for the update.
Could you please put new report about the issue in QC?  I will open it.

Peter Hull at 2/4/2010 3:14:12 AM -
Done, see report number 81795.

Server Response from: ETNACODE01