Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new line option before/after the arrow when using an expression body for a method/property #46603

Open
vsfeedback opened this issue Aug 6, 2020 · 2 comments
Labels
Area-IDE Feature Request IDE-Formatter Code formatter and/or smart indent
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


I want the option to add a new line before(or after) the arrow when using an expression body for a method (or property).

Currently, the following code using long type names will not break on a new line.
One line is too long.

public static System.Collections.Generic.IList<Guid> CreateList() => new  System.Collections.Generic.List<Guid>();

If possible, I would like to see a line break before(or after) an arrow.
(The first line is the same as in the block body!)

public static System.Collections.Generic.IList<Guid> CreateList()
    => new System.Collections.Generic.List<Guid>();

My editorconfig is below.

csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

Thanks.


Original Comments

Feedback Bot on 7/31/2020, 02:40 AM:

Thank you for taking the time to provide your suggestion.  We will do some preliminary checks to make sure we can proceed further.  We'll provide an update once the issue has been triaged by the product team.

@sharwell sharwell added Area-IDE Feature Request IDE-Formatter Code formatter and/or smart indent labels Aug 6, 2020
@jinujoseph jinujoseph added this to the Backlog milestone Aug 18, 2020
@Youssef1313
Copy link
Member

Duplicate of #21631.

@OSchmitz
Copy link

I found this open feature request when I googled how to do that exact thing, wrap the line before the arrow operator when using expression bodied methods. Later I discovered that ReSharper has a formatting rule like this, so if you use RS this might be a workaround for anyone waiting for this to be implemented in VS natively.

The RS rules are

[resharper_]csharp_wrap_before_arrow_with_expressions, [resharper_]wrap_before_arrow_with_expressions

You can also find them in Extensions > ReSharper > Options > Code Editing > C# > Formatting Style > Line Breaks and Wrapping > Arrangement of Expression Bodied Members

Hope this helps. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request IDE-Formatter Code formatter and/or smart indent
Projects
None yet
Development

No branches or pull requests

5 participants