roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

An easier way to execute 'Wrap every parameter -> Indent all parameters'

Open vsfeedback opened this issue 3 years ago • 21 comments

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


Say I have the following method

public Task HandleAsync(ActivityCreated domainEvent, CancellationToken cancellationToken)
{
    throw new System.NotImplementedException();
}

But I wish to reformat it like this (indent all parameters):

public Task HandleAsync(
    ActivityCreated domainEvent, 
    CancellationToken cancellationToken)
{
    throw new System.NotImplementedException();
}

I know I can move my cursor to any of the param names and enter Ctrl + . to select the option, but it would be nice to have a faster shortcut to do this, or some way of configuring VS to do this wrap/indent automatically after using Ctrl + . do auto implement some interface method


Original Comments

Feedback Bot on 2/16/2022, 10:59 PM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. You will hear from us in about a week on our next steps.

vsfeedback avatar Mar 03 '22 17:03 vsfeedback

cc @CyrusNajmabadi

jinujoseph avatar Mar 09 '22 19:03 jinujoseph

Let's have this implemented... :D

Original post @ StackOverflow: https://stackoverflow.com/q/71136991/114029

leniel avatar Oct 20 '22 15:10 leniel

I would love that one as well.

To have the possibility to do this refactoring on whole project or solution. It would make life so much easier.

Or ability to do it automatically on save would be even better

tomasfil avatar Feb 16 '23 21:02 tomasfil

+1

barba3 avatar Mar 01 '23 01:03 barba3

We would take a PR that updated the existing refactoring and added fix-all support for it. If any interested parties here would like to contribute that, that would be great.

CyrusNajmabadi avatar Mar 01 '23 01:03 CyrusNajmabadi

Please implement.

halonzo7 avatar Mar 30 '23 18:03 halonzo7

@halonzo7 if you're interested in contributing a PR to help implement this, we'd be very happy to work with you on it :)

CyrusNajmabadi avatar Mar 30 '23 18:03 CyrusNajmabadi

@halonzo7 if you're interested in contributing a PR to help implement this, we'd be very happy to work with you on it :)

Tell me how to get started, would be interested in helping.

halonzo7 avatar Mar 30 '23 18:03 halonzo7

Teh wrapping code is implemented as a refactoring here: https://github.com/dotnet/roslyn/blob/main/src/Features/Core/Portable/Wrapping/AbstractWrappingCodeRefactoringProvider.cs

(with vb and c# specific subclasses as this is a cross language feature).

CodeRefactoringProviders support the concept of 'Fix All' which can be provided by overriding this method: https://github.com/dotnet/roslyn/blob/8675c16d105cc816ab368b2276ff14325aa2fb2d/src/Workspaces/Core/Portable/CodeRefactorings/CodeRefactoringProvider.cs#L30

You'd then have the refactoring do the work accordingly on the scope the user wanted.

CyrusNajmabadi avatar Mar 30 '23 18:03 CyrusNajmabadi

Is it possible to assign a shortcut to that refactoring?

vyrp avatar Apr 05 '23 07:04 vyrp

Any updates to this issue? I also want this feature to be executable by a keyboard shortcut.

ClassyCircuit avatar Oct 31 '23 08:10 ClassyCircuit

@ClassyCircuit the issue remains on the backlog. We'd likely take a good pr here though from the community if anyone is interested.

CyrusNajmabadi avatar Oct 31 '23 14:10 CyrusNajmabadi

It would be great if this could be added to the existing Code Style preferences, so it can then be included in the Code Cleanup functionality.

BenJenkinson avatar Mar 06 '24 11:03 BenJenkinson

It would be very useful indeed, rather than using AutoHotKey...

GiottoVerducci avatar Mar 13 '24 17:03 GiottoVerducci

Surprised that we have this feature implemented for C# but not C++

dev-dakky avatar Mar 18 '24 16:03 dev-dakky

@dev-dakky The maintainers of this repository have no impact on the C++ features, and it's unlikely they will see your comment here. I would recommend filing a feedback using the Suggest a feature tool in Visual Studio.

sharwell avatar Mar 18 '24 16:03 sharwell

First of all I'm glad there are more folks looking for this feature 🎆 Second of all I have a whole team waiting for this feature :) Many upvotes!

greendimka avatar Apr 03 '24 08:04 greendimka

Ping! 😄 Would be nice to have it in the Code Cleanup :) as well as 'Add Argument Names'

alikleit avatar Apr 24 '24 09:04 alikleit

Ping! 😄 Would be nice to have it in the Code Cleanup :) as well as 'Add Argument Names'

@alikleit as stated above: the issue remains on the backlog. We'd likely take a good pr here though from the community if anyone is interested.

CyrusNajmabadi avatar Apr 24 '24 14:04 CyrusNajmabadi

You can use the extension CodeRush!

jerviscui avatar Jun 07 '24 11:06 jerviscui

I'd love this feature!

juliannamello avatar Jul 20 '24 06:07 juliannamello