Roslyn: IDE0024 (Use expression body for properties): Removing extra whitespace

Created on 10 Jan 2017  路  2Comments  路  Source: dotnet/roslyn

Version Used: VS 2017 RC 15.0.26020.0

Steps to Reproduce:

  1. Start with this a sample program:
    ```c#
    class Program
    {
    static void Main(string[] args) { }

    private string _prop = "HELLO THERE!";
    public string Prop { get { return _prop; } }

    public string OtherThing => "Pickles";
    }

2. `Ctrl+.` on `public string Prop { get { return _prop; } }`
3. Select "Use expression body for properties"
4. Observe the line below the `Prop` property being removed, result:
```c#
    public string Prop => _prop;
    public string OtherThing => "Pickles";

Screenshot:
screen shot 2017-01-10 at 08 26 44

Expected Behavior: Suggestion should not remove the unrelated line below the property.

Actual Behavior: Line below the property is removed.

Area-IDE Bug

Most helpful comment

All 2 comments

A more severe instance of this is when there was no extra line to remove, causing multiple properties to appear on a single line. Here's an example:
screen shot 2017-01-10 at 08 54 43

Before:
```c#
public NameValueCollection Form
{
get { return formVariables; }
}
private NameValueCollection formVariables = new NameValueCollection();


After:
```c#
public NameValueCollection Form => formVariables; private NameValueCollection formVariables = new NameValueCollection();
Was this page helpful?
0 / 5 - 0 ratings