How to auto-generate property code

Just installed ReSharper and I'm trying to get the ReSharper > Code >
Generate > Read property to work but no luck. Here's what I'm doing:

1. New project
2. New class
3. place cursor below default constructor
4. hit Alt-Ins and I get the Generate dialog, but Read property is disabled

I'm probably using this completely wrong actually. What I'm really after is
the ability to auto-gen a property. So what I'd like to do is this:

1. Hit "some hotkey", be presented with a dialog for a new property name
2. select property name and type
3. have it auto-generate this:

public ]]>
{
get { return name; }
set { name = value; }
}

I'm sure there is a way to do this but I'm too sleepy to figure it out.

Shawn


3 comments
Comment actions Permalink

Shawn,

Properties are generated from fields. Type 'private int foo;' and press
'Alt+Ins'.
--
Sergey V. Coox
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

He does make a valid point though... it'd be nice to be able to just type
in a Property Name, and have it generate everything, including the private
field of the proper name...

"Sergey V. Coox (JetBrains)" <qx@intellij.com> wrote in message
news:dhg2qf$auh$1@is.intellij.net...

Shawn,

>

Properties are generated from fields. Type 'private int foo;' and press
'Alt+Ins'.
--
Sergey V. Coox
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"



0
Comment actions Permalink

Until it's there, it's fairly easy to do using a code template, no real
refactoring there.

Still, I've noted something similar a while ago, it would be considered
for 2.0:

Wiebe

Wiebe Tijsma wrote:
> Hi,
>
> Currently if I access a non-existent property on a class, I get the
> options:
>
> - Create Property
> - Create get/set Property
>
> Most of the time, I also want to add a private field with the same name,
> but without the initial capitalization. So it would be great to have an
> extra option:
>
> - Create get/set + private field
>
> Thanks!
>
> Wiebe Tijsma



Paul Bradshaw wrote:

He does make a valid point though... it'd be nice to be able to just type
in a Property Name, and have it generate everything, including the private
field of the proper name...

"Sergey V. Coox (JetBrains)" <qx@intellij.com> wrote in message
news:dhg2qf$auh$1@is.intellij.net...

>>Shawn,
>>
>>Properties are generated from fields. Type 'private int foo;' and press
>>'Alt+Ins'.
>>--
>>Sergey V. Coox
>>JetBrains, Inc
>>http://www.jetbrains.com
>>"Develop with pleasure!"
>>


0

Please sign in to leave a comment.