Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-248229: Generated C# properties do not adhere to R# layout settings

$
0
0
Reporter William Dean (willdean) William Dean (willdean)
Created Apr 6, 2011 3:24:31 PM
Updated Dec 27, 2011 8:11:30 PM
Resolved Dec 27, 2011 8:11:30 PM
Priority Normal
Type Bug
Fix versions Next
State Fixed
Assignee Alexander Shvedov (shvedov)
Subsystem Generate Action
Affected versions No Affected versions
Fixed in build No Fixed in build
We are using the default R# settings for C# property layouts ("Place simple accessor on single line" is TRUE). We also use the default, BSD-style, brace layout.
This means a simple property, properly formatted, looks like this:

int MyProp
{
    get { return _myProp; }
    set { _myProp = value; }
}


However, when R# creates a property from a quick-fix on a call to a new property name, followed by the selection of "Create and use _myProp as backing field", it lays-out the property like this:

int MyProp
{
    get {
        return _myProp;
    }
    set {
        _myProp = value;
    }
} <--- Position X - see below


This is incorrect - nothing is configured to use K&R style layout, so R# shouldn't generate K&R-style code.

Furthermore, if we now over-type the brace at position 'X', as a way of forcing the property to reformat, it then looks like this:

int MyProp
{
    get 
    {
        return _myProp;
    }
    set
    {
        _myProp = value;
    }
} 


This is also wrong - that's not the correct format for a property, though at least it's not K&R.

Finally, if you run Ctrl-E-F (quick fix, with reformat enabled), then the property is arranged correctly.

Viewing all articles
Browse latest Browse all 106942

Trending Articles