Customize braces with StyleCop

Is it possible to get StyleCop to say that this is the right way to use curly braces?

if (request.Query == string.Empty) {
    return SearchResponse.Empty;
}

But not this

if (request.Query == string.Empty)
    return SearchResponse.Empty;

Or that:

if (request.Query == string.Empty)
{
    return SearchResponse.Empty;
}

I also want this behavior for if, else, else if, while, foreach and for. But not for class declarations or method declarations.

+3
source share
1 answer

I do not think he does it out of the box; however, StyleCop comes with an SDK that contains instructions on how to create your own rules. Although it would be very helpful if someone already created a custom rule that executes what you are describing, you may find that you must roll yourself.

SDK, .CHM, , . , http://stylecop.codeplex.com .

!

+3

Source: https://habr.com/ru/post/1756701/


All Articles