Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting Resharper backing fields for properties in C#

Tags:

c#

resharper

So this is a follow-up to Keith Nicholas' question from 2 years ago:

Formatting Resharper backing fields for properties in C#

My guess is this would probably involve a custom Type Members Layout. Is there a way to to this yet in the latest Resharper version (as of now, it's 5.1) yet?

like image 322
David McClelland Avatar asked Jul 16 '10 16:07

David McClelland


2 Answers

Version 9.1 has a new option:

Resharper > Options > Code Editing > Place backing field above property

https://youtrack.jetbrains.com/issue/RSRP-411980#comment=27-961304

like image 56
Lakerfield Avatar answered Oct 21 '22 17:10

Lakerfield


In Resharper 6.1 I have this kind of a template, that may solve the question, or at least help others.

Using the 'shortuct' + TAB combination, I call mine nprop, and got further in adding a comment section.

private $TYPE$ _$NAMEP$;

/// <summary>
/// The $CLASS$ $NAMEC$
/// </summary>
public $TYPE$ $NAME$
{
    get { return _$NAMEP$; }
    set { _$NAMEP$ = value; }
}

Here's an image of the extra customisation to help rename things so it's just a matter of typing 2 values.

property with template how-to

like image 1
Nick Josevski Avatar answered Oct 21 '22 16:10

Nick Josevski