Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-287892: "Use object initializer" drops item added to a list

$
0
0
Reporter Tero Teelahti (Tero.Teelahti) Tero Teelahti (Tero.Teelahti)
Created Jan 20, 2012 12:50:04 PM
Updated Jan 20, 2012 7:11:56 PM
Resolved Jan 20, 2012 5:34:21 PM
Priority Normal
Type Bug
Fix versions Next
State Fixed
Assignee Evgeny Pasynkov (pasynkov)
Subsystem Refactoring
Affected versions 6.1
Fixed in build 6.5.1.2889
When using "Use object initializer" command to a code block demonstrated below, the one new item added to the list is just dropped without notifying. Expected result would be to keep the item adding line (target.items.Add(new DemoItem()) below) after object initializer block.


namespace ReSharperUseObjectInitializerSkippingListItemAddBugRepro
{
using System.Collections.Generic;

class Program
{
static void Main(string[] args)
{
// Refactor with R# "Use object initializer" to see
// that the added item is skipped
var target = new DemoModel();
target.Items = new List<DemoItem>();
target.Items.Add(new DemoItem());

// Refactoring result will be this:
// var target = new DemoModel { Items = new List<DemoItem>() };
}
}

public class DemoModel
{
public List<DemoItem> Items { get; set; }
}

public class DemoItem
{
}
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>