Re: VS2022 format all files

2023-04-11 Thread Greg Keogh
Bingo! Thanks David, I'll admit that I have neglected the Code Cleanup
feature and it went out of my mind. I have fiddled with it occasionally
over the years but I couldn't get it to work the way I wanted. But this
time I concentrated and:

• Set all the Tools Options C# preferences I want (takes time).
• Saved the .editorconfig file in the solution folder.
• Configure Code Cleanup -- *It's hard to know which Available fixers to
include, because you don't know which specific preferences are inside each
fixer. I noticed that using statements weren't being moved to the outside
and I wasn't getting file-scoped namespaces, so I had to scroll down the
Available list and guess which ones to include. I noticed I needed an
experimental one to remove excess blank lines.*
• Run the cleanup. *I accidentally clicked the main window while the
cleanup was running and it went grey and asked if I wanted to wait for the
app to respond, which it eventually did, but the progress dialog was hidden
and only visible by holding Alt+Tab.*

So overall, after you take time to get everything just right, it works like
a dream. It's hard to know how the .editorconfig file and the VS options
are affecting the process or if they are fighting each other. Maybe the
file takes preference outside VS when using the dotnet format command
(which I haven't tried yet).

I'd love an option to remove blank lines immediately inside method opening
and closing braces so you don't get this:

void Something()
{

WriteLine("I hate the blank lines around this");

}

*Greg K*

On Wed, 12 Apr 2023 at 11:18, David Kean  wrote:

> Both of these options can do this on a per solution, project, document
> basis.
>
>
>
>
> If you want to this via command-line, look at *dotnet format*. These all
> work better if you’ve got a good .editorconfig that calls the style
> .
> You can have IntelliCode automatically generate one based on the project
> via Add -> New Item -> Editor Config (IntelliCode).
>
> *From:* Greg Keogh via ozdotnet ozdotnet@ozdotnet.com
> *Sent:* Wednesday, April 12, 2023 11:03 AM
> *To:* ozDotNet 
> *Cc:* Greg Keogh 
> *Subject:* VS2022 format all files
>
>
>
> Folks, is there a way to apply commands like *Format Document* and *Remove
> and Sort Usings* to multiple C# files, perhaps all open files or all
> files in the project?
>
>
>
> Web searches suggest it's not possible at the moment. I see an Extension
> for this which looks a bit flakey and I won't try it yet.
>
>
>
> Taking this even further, I occasionally need to "beautify" C# code in
> hundreds of files in projects to fix things like indentation, tabs, usings
> and more fiddly things like removing excess blank lines, putting gaps
> between methods, etc. That is, I want to bring code that is sometimes
> haphazardly formatted back to a vanilla format acceptable to typical
> developers.
>
>
>
> Cheers,
>
> *Greg Keogh*
>


Re: VS2022 format all files

2023-04-11 Thread Alan Ingleby
There's also a command line tool called dotnet-format which may do part of
what you are looking for.  https://github.com/dotnet/format

Apparently quite extensible.

On Wed, 12 Apr 2023 at 11:18, Greg Keogh via ozdotnet 
wrote:

> Resharper?
>>
>
> I accidentally used it for one day back in about 2010 and it was a
> constant battle of keystrokes and interruptions that drove me bonkers and
> I'm glad I've never seen it again. I thought Reshaper was basically
> redundant now that recent VS releases have incorporated most of its
> original features (vague gossip I've heard). In any case, even if it does
> have the global formatting that I desire, I don't want to buy it or install
> it --
> *Greg K*
> --
> ozdotnet mailing list
> To manage your subscription, access archives: https://codify.mailman3.com/



-- 
Alan Ingleby


RE: VS2022 format all files

2023-04-11 Thread David Kean
Both of these options can do this on a per solution, project, document basis.

[cid:image001.png@01D96D2F.DBC4AB50]

If you want to this via command-line, look at dotnet format. These all work 
better if you’ve got a good .editorconfig that calls the 
style.
 You can have IntelliCode automatically generate one based on the project via 
Add -> New Item -> Editor Config (IntelliCode).
From: Greg Keogh via ozdotnet 
ozdotnet@ozdotnet.com
Sent: Wednesday, April 12, 2023 11:03 AM
To: ozDotNet 
Cc: Greg Keogh 
Subject: VS2022 format all files

Folks, is there a way to apply commands like Format Document and Remove and 
Sort Usings to multiple C# files, perhaps all open files or all files in the 
project?

Web searches suggest it's not possible at the moment. I see an Extension for 
this which looks a bit flakey and I won't try it yet.

Taking this even further, I occasionally need to "beautify" C# code in hundreds 
of files in projects to fix things like indentation, tabs, usings and more 
fiddly things like removing excess blank lines, putting gaps between methods, 
etc. That is, I want to bring code that is sometimes haphazardly formatted back 
to a vanilla format acceptable to typical developers.

Cheers,
Greg Keogh


Re: VS2022 format all files

2023-04-11 Thread Greg Keogh
>
> Resharper?
>

I accidentally used it for one day back in about 2010 and it was a constant
battle of keystrokes and interruptions that drove me bonkers and I'm glad
I've never seen it again. I thought Reshaper was basically redundant now
that recent VS releases have incorporated most of its original features
(vague gossip I've heard). In any case, even if it does have the global
formatting that I desire, I don't want to buy it or install it --
*Greg K*


Re: VS2022 format all files

2023-04-11 Thread Alan Ingleby
Resharper?

On Wed, 12 Apr 2023 at 11:04, Greg Keogh via ozdotnet 
wrote:

> Folks, is there a way to apply commands like *Format Document* and *Remove
> and Sort Usings* to multiple C# files, perhaps all open files or all
> files in the project?
>
> Web searches suggest it's not possible at the moment. I see an Extension
> for this which looks a bit flakey and I won't try it yet.
>
> Taking this even further, I occasionally need to "beautify" C# code in
> hundreds of files in projects to fix things like indentation, tabs, usings
> and more fiddly things like removing excess blank lines, putting gaps
> between methods, etc. That is, I want to bring code that is sometimes
> haphazardly formatted back to a vanilla format acceptable to typical
> developers.
>
> Cheers,
> *Greg Keogh*
> --
> ozdotnet mailing list
> To manage your subscription, access archives: https://codify.mailman3.com/



-- 
Alan Ingleby


VS2022 format all files

2023-04-11 Thread Greg Keogh
Folks, is there a way to apply commands like *Format Document* and *Remove
and Sort Usings* to multiple C# files, perhaps all open files or all files
in the project?

Web searches suggest it's not possible at the moment. I see an Extension
for this which looks a bit flakey and I won't try it yet.

Taking this even further, I occasionally need to "beautify" C# code in
hundreds of files in projects to fix things like indentation, tabs, usings
and more fiddly things like removing excess blank lines, putting gaps
between methods, etc. That is, I want to bring code that is sometimes
haphazardly formatted back to a vanilla format acceptable to typical
developers.

Cheers,
*Greg Keogh*