How can I format a Lamba part of an Anonymous method to remain on same line as original statement?

I have this:

                var actions = new Queue<Action>();
                actions.Enqueue(() =>
                {
                    Console.Write("");
                });

But ReSharper always changes it to:

                var actions = new Queue<Action>();
                actions.Enqueue(
                    () =>
                    {
                        Console.Write("");
                    });
 

How can I configure ReSharper to either always put the () => on the same line as the original statement (preferred) OR at least stop it from reformatting it automatically when you close the last brace or semi-colon?

0
3 comments

Hello,

 

Most probably the setting - ReSharper | Options | Code Editing | C# | Formatting Style | Line Breaks and Wrapping | Arrangement of invocations | Prefer to wrap after ‘(’ in invocation is set to true.

Please check if disabling the option makes any difference.

Thank you.

0

That does work. However, that setting also affects wrapping of normal methods. So now we get this:

                MyMethod(param1,
                    param2,
                    param3,
                    param4);
 

Instead of:

                MyMethod(
                    param1,
                    param2,
                    param3,
                    param4);

Maybe a separate enhancement is needed for the specific scenario I mentioned above.

0

Thank you for the reply.

I've got your point. Here's a corresponding feature request - RSRP-467905. Please feel free to comment or vote for it.

Let me know if you have any more questions.

 

1

Please sign in to leave a comment.