Can Resharper have special settings for enum?

I'm using Resharper 5.1.1 to reformat my code (Cleanup Code, Ctrl+E, Ctrl+C). I can't get it to format my code the way I want it to. I want my code to look like this:

    public class Person
    {
        public enum Sex {Male, Female}

        public Sex Gender { get; set; }

        public Person(Sex gender)
        {
            Gender = gender;
        }
    }


My problem is with the enum. Since an enum is a type, just as a class is a type, they are treated the same. Therefor, the enum is formatted as

    public enum Sex
    {
        Male,
        Female
    }


The curly braces of the type (i.e. the enum) are placed on a separate line and the members are also placed on a separate line. For a Class that is exactly what I want. But for a (simple) enum I just want them on a single line.

For an auto property there is an exception (Place abstract property/indexer/event declaration on single line), so  the auto property is formatted the way I want it to.

Is there an option in Resharper to have it place an enum on a single line?

2 comments

Hello Dick,

At the moment there's no option to place enum declarations on a single line.
I've logged a feature request: http://youtrack.jetbrains.net/issue/RSRP-203629
and you're welcome to vote for it. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I'm using Resharper 5.1.1 to reformat my code (Cleanup Code, Ctrl+E,
Ctrl+C). I can't get it to format my code the way I want it to. I want
my code to look like this:

 {
> public enum Sex {Male, Female}
> public Sex Gender { get; set; }
> 
> public Person(Sex gender)
> {
> Gender = gender;
> }
> }]]>

My problem is with the enum. Since an enum is a type, just as a class
is a type, they are treated the same. Therefor, the enum is formatted
as

 {
> Male,
> Female
> }]]>

The curly braces of the type (i.e. the enum) are placed on a separate
line and the members are also placed on a separate line. For a Class
that is exactly what I want. But for a (simple) enum I just want them
on a single line.

For an auto property there is an exception (Place abstract
property/indexer/event declaration on single line), so  the auto
property is formatted the way I want it to.

Is there an option in Resharper to have it place an enum on a single
line?

---
Original message URL:
http://devnet.jetbrains.net/message/5282599#5282599



0

Hi Andrey,

Thanks for creating the request. However, the format of the current situation is incorrect in the request. I have already posted a comment on it, but maybe you can edit the request to fix the formatting.

Update: When I wrote the above I was on someone else's computer. Now that I am at home, the formatting in the request seems just fine. So either something has changed, or the browser at this other computer was doing something wrong. I see the correct formatting now in IE, Chrome and FireFox.

0

Please sign in to leave a comment.