Roslyn: Remove Unnecessary Usings doesn't remove empty line

Created on 8 Feb 2017  路  6Comments  路  Source: dotnet/roslyn

Version Used: VS2017RC 15.0.26206.0

Steps to Reproduce:

Exec Remove Unnecessary Usings:

```C#
// Hello, World!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SomeNamespace
{
}


**Expected Behavior**:

```C#
// Hello, World!

namespace SomeNamespace
{
}

Actual Behavior:

```C#
// Hello, World!

namespace SomeNamespace
{
}
```

Area-IDE Bug Resolution-Duplicate help wanted

All 6 comments

Remove empty lines should be an additional Code Fix.

This should be fixed. But it's somewhat low priority simply due to it being very rare for a file to have zero usings in it.

I'm not sure it's that rare. Take the example of simple Model objects, e.g. in one of my projects

// License header

using System;

namespace Milkman.Api.Models
{
  class TransactionRecord
  {
     string CustomerId { get; set; }
     string BraintreeId { get; set; }
     decimal TotalBilled { get; set; }

     // Common to all objects stored in ElasticSearch
     string ElasticSearchId { get; set; } 
     DateTime Created { get; set; }
     DateTime LastModified { get; set; }
  }
}

What happened next was that I extracted the common code for elasticsearch objects to a base-class in Milkman.Api.Models, causing a redundant import, triggering this bug.

... and I guess another simpler example could be the creation of a new file, adding a license header, then calling the fix-it.

Those are both pretty rare cases :)

Was this page helpful?
0 / 5 - 0 ratings