csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Consider always putting generic type constraints onto a new line

Open belav opened this issue 4 years ago • 0 comments

According to this stylecop rule generic type constraints should always be on a new line.

I think I am on board with modifying this

    public static T CreatePipelineResult<T>(
        T result,
        ResultCode resultCode,
        SubCode subCode,
        string message = null
    ) where T : PipeResultBase
    {
// vs
    public static T CreatePipelineResult<T>(
        T result,
        ResultCode resultCode,
        SubCode subCode,
        string message = null
    ) 
        where T : PipeResultBase
    {

But it makes less sense in cases like this

    public int Foo<T>(T obj) where T : U;
// vs
    public int Foo<T>(T obj) 
        where T : U;

From the files in csharpier-repos, only 39% of generic type constraints are on a new line. But that doesn't take into account super short examples vs long ones.

belav avatar Dec 21 '21 16:12 belav