llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.25k stars 11.66k forks source link

Align LINQ Query Clauses #61967

Open StrangeRanger opened 1 year ago

StrangeRanger commented 1 year ago

It'd be nice to have a feature in clang-format, that makes it possible to align C# LINQ query clauses under the from clause, or in some other way. Something like the following:

var seattleCustomers = from customer in customers
                       where customer.City == "Seattle"
                       select customer.Name;

Here is a link to Microsoft's website providing more information on what I'm talking about: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions#linq-queries

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-format

Jorge-Pomo commented 1 year ago

You can do this by using linq var seattleCustomers = customers.AsQueryable().where(customer => customer.City == "Seattle").Select(customer => customer.Name)

StrangeRanger commented 1 year ago

@Jorge-Pomo I know, but it'd be nice if clang-format could also format the other method that I mentioned. Plus I often like using how I did it instead of the way you suggest. Comes down to personal preference and the ability to properly format either method would be nice.