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?
Update After posting the same question on the Resharper forum, I've been told it currently isn't possible. A Feature Request has been created for it. If you also feel this is an option you'd 开发者_Go百科like to see in a future version of Resharper, please vote for the request.
Taking a look at the options of ReSharper, I found no option, too.
Maybe if you post the question in the ReSharper forum you can get direct response from their developers or support engineers.
Old question but the answer has changed.
In Visual Studio 2019 with Resharper 2019.1.1 (and probably in older ones) you can configure line breaks of enums in:
Extensions > ReSharper > Options... > Code Editing > C# > Formatting Style > Line Breaks and Wrapping > Arrangement of Enumerations
精彩评论