csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Inconsistent line breaks with lambda notation

Open samtrion opened this issue 2 years ago • 3 comments

 private bool ShouldNotBeDescribedKind(ITypeDefinition typeDefinition) =>
        typeDefinition.Kind switch
        {
            TypeKind.Class => (_configuration.Kinds & DescribeKind.Class) != DescribeKind.Class,
            TypeKind.Interface
                => (_configuration.Kinds & DescribeKind.Interface) != DescribeKind.Interface,
            TypeKind.Struct => (_configuration.Kinds & DescribeKind.Struct) != DescribeKind.Struct,
            TypeKind.Delegate
                => (_configuration.Kinds & DescribeKind.Delegate) != DescribeKind.Delegate,
            TypeKind.Enum => (_configuration.Kinds & DescribeKind.Enum) != DescribeKind.Enum,
            TypeKind.Void
            or TypeKind.NInt
            or TypeKind.NUInt
            or TypeKind.FunctionPointer
                => throw new UnreachableException(),
            _ => true,
        };

In my opinion these are several very similar errors.

  1. lambda notation for methods is wrapped after the =>.
  2. lambda notation for switch cases is wrapped before the =>, if line length is too long.
  3. lambda notation for switch cases will wrap before =>, if pattern matching.

This does not correspond to the expected behavior. Basically I would expect either a consistent wrap before or after =>. In the special case of the switch case notation, even always independent of the line length.

samtrion avatar Jan 23 '23 10:01 samtrion

related #205

belav avatar Feb 04 '23 18:02 belav

related #348

belav avatar Feb 04 '23 19:02 belav

Also related: #836 I personally would like all three cases to break after =>.

jods4 avatar Aug 16 '23 20:08 jods4