views:

244

answers:

3

Is there a way to create an auto property via code snippet using ReSharper? Like the prop for VS?

A: 

Yes. You can setup any snippet you wish. These are called "Live Templates" in Resharper, and have a lot more functionality than the VS versions. Just choose "Resharper->Live Templates.." in VS to edit them.

Reed Copsey
+2  A: 

You can create a Live Template

Just go to the Resharper menu, and choos Live Templates. Click the little green + icon and add this:

public $type$ $name$ { get; set; }

Then give the wanted shortcut, and you are good to go.

Luhmann
+3  A: 

Resharper 5 has a prop snippet which goes to auto-property. Does 4.5 not?

pdr
It absolutely does. Generate Property allows the user to select which form, autoprop, prop with backing field or "throw new NotImplementedException()".
Peter Lillevold
but how do I do this via keyboard with R#?
CoffeeAddict
I know about Alt + Ins, is that what you're talking about? But I can't get to properties if I have no backing fields defined in that context menu.
CoffeeAddict
@coffeeaddict: Just put your cursor where you want the property and type prop<Tab> (you can probably get away with just typing pr<Tab>)
pdr
I see no prop snippet when I do a Ctrl + J in 4.5
CoffeeAddict
lol, I guess I was thinking the prop was the VS prop. duh, it does give you an automatic property. It must be using R#?
CoffeeAddict
I'll be honest, I'm never sure which app is doing what, it's been so long since I worked without R#. I know if I type prop, I get an auto-property; that's all I need to know. :)
pdr