Empty lines not removed?
See original GitHub issueJust installed dotnet-format and tested with the following code (empty lines intended). Used command was
dotnet format Test.sln --fix-whitespace --fix-style
. I expected the empty lines to be removed, but they remained. How to apply a more strict formatting that removes unnecessary empty lines?
Tested on this code, which is input and output at the sae time (meaning output remains unchanged)
using System;
namespace Test
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main()
{
DemoAsync().Wait();
}
static async Task DemoAsync()
{
var d = new Dictionary<int, int>();
for (int i = 0; i < 10000; i++)
{
int id = Thread.CurrentThread.ManagedThreadId;
int count;
d[id] = d.TryGetValue(id, out count) ? count + 1 : 1;
await Task.Yield();
}
foreach (var pair in d) Console.WriteLine(pair);
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Remove Empty Lines Online tool
Remove Empty Lines is easy to use tool to remove empty lines. Copy, Paste and delete empty lines. Empty lines may be used...
Read more >How to Get Rid of Empty Lines of Code in Any Text Editor
Step-by-Step: How to Remove Blank Lines of Code Using a Text Editor · In the file you want to clean up, select two...
Read more >How to Remove Blank Lines from a File
Steps and help with removing blank lines from text and a file using Notepad++, TextPad, Word, Notepad, WordPad, or a regular expression.
Read more >Remove blank (empty) lines
I must be very stupid. I select a section (right-click and hold, select, release right-click) Edit > Line operations > Remove Empty Lines...
Read more >Removing empty lines or blank lines - Actions
TAD-Remove Empty Lines Remove any empty lines from the draft. Empty lines may have no content, whitespace counts as content.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@anthony-steele-cko Glad things are working for you now. To fix both whitespace formatting and analyzer reported issues in the same run, you can use the command
dotnet format --fix-whitespace --fix-analyzers warn
.I confirm that this works for me. This time I have a
Directory.Build.Props
file containing:In the
.editorconfig
I have file markup as given above.Note that when opening the soltution in VS, I have errors for e.g.
I run
dotnet format --fix-analyzers
These are all fixed! 🎉 Blank lines are gone.
More conventional spacing, issues e.g.
public SomeClass ( string pk , string sk )
was not fixed by this run, so I rundotnet format
a second time with no args, and they are fixed, I getpublic SomeClass(string pk, string sk)
I can also confirm that without the
.editorconfig
markup to make these errors not warnings,dotnet format --fix-analyzers warn
will remove the blank lines.Thank you.