[548] Backing Field Naming

When I generate a property and then a backing field it doesn't seem to respect my naming conventions.

private void comboCategories_SelectedIndexChanged(object sender, EventArgs e)
{
Category = comboCategories.SelectedItem as string;
}

Create property 'Category' and then selecting 'Backing Field' gives:

private string Category
{
get { return _Category; }
set { _Category = value; }
}

I have a name prefix set as '_' so I'd expect the backing variable to be _category. When I rename _Category this is what's offered.

Is this the expected behaviour?

7 comments
Comment actions Permalink

Hi Sean,

+1 for this request! the private field naming misbehaves when defining
an _ as a prefix.

In some cases R# will generate pascal cased field names, and sometimes
camel case.

Best Regards,

Wiebe Tijsma


sean kearon wrote:

When I generate a property and then a backing field it doesn't seem to respect my naming conventions.

private void comboCategories_SelectedIndexChanged(object sender, EventArgs e)
{
Category = comboCategories.SelectedItem as string;
}

Create property 'Category' and then selecting 'Backing Field' gives:

private string Category
{
get { return _Category; }
set { _Category = value; }
}

I have a name prefix set as '_' so I'd expect the backing variable to be _category. When I rename _Category this is what's offered.

Is this the expected behaviour?

0
Comment actions Permalink

Hello Wiebe,

There was a bug fixed in ReSharper 3.1 when some features wouldn't use correct
naming style. Do you use latest build?

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


WT> Hi Sean,
WT>
WT> +1 for this request! the private field naming misbehaves when
WT> defining an _ as a prefix.
WT>
WT> In some cases R# will generate pascal cased field names, and
WT> sometimes camel case.
WT>
WT> Best Regards,
WT>
WT> Wiebe Tijsma
WT>
WT> sean kearon wrote:
WT>
>> When I generate a property and then a backing field it doesn't seem
>> to respect my naming conventions.
>>
>> private void comboCategories_SelectedIndexChanged(object sender,
>> EventArgs e)
>> {
>> Category = comboCategories.SelectedItem as string;
>> }
>> Create property 'Category' and then selecting 'Backing Field' gives:
>>
>> private string Category
>> {
>> get { return _Category; }
>> set { _Category = value; }
>> }
>> I have a name prefix set as '_' so I'd expect the backing variable to
>> be _category. When I rename _Category this is what's offered.
>>
>> Is this the expected behaviour?
>>


0
Comment actions Permalink

Hi Ilya

I'm now using the full 3.1 edition (3.1.584.3) and I still get the same bug.

Cheers

Sean

0
Comment actions Permalink

Hello sean,

What exactly are you doing when the bug manifests itself?

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


sk> Hi Ilya
sk>
sk> I'm now using the full 3.1 edition (3.1.584.3) and I still get the
sk> same bug.
sk>
sk> Cheers
sk>
sk> Sean
sk>


0
Comment actions Permalink

Hi Ilya

Given:

private string _foo;
public string Foo
{
get { return _foo; }
}

Hit rename on Foo (line 2), change to FooBar, click next to 'Rename Related Symbols' which offers to rename '_foo' to '_FooBar'. (By the way, it would be great to be able to F2 at this point an go straight into editing the new related symbol name.) This leaves:

private string _FooBar;
public string FooBar
{
get { return _FooBar; }
}

Then if I rename on '_FooBar' the dialog offers the (correct) name of '_fooBar'.

Cheers

Sean

0
Comment actions Permalink

Hello,

We appreciate your feedback.

The corresponding JIRA request has been created, and you are welcome to monitor
its status at http://www.jetbrains.net/jira/browse/RSRP-57385.

Best regards,
- Development Team.


0
Comment actions Permalink

This is the same as RSRP-30221 reported on October 20, 2006.

"Ilya Ryzhenkov" <orangy@jetbrains.com> wrote in message
news:76a2bd0b14f7898ca3646480c62b6@news.intellij.net...

Hello,

>

We appreciate your feedback.

>

The corresponding JIRA request has been created, and you are welcome to
monitor its status at http://www.jetbrains.net/jira/browse/RSRP-57385.

>

Best regards,
- Development Team.

>

0

Please sign in to leave a comment.