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

RSRP-124400: Suggested CA 'Convert for to foreach' breaks code

$
0
0
Reporter Vladimir Reshetnikov (nikov) Vladimir Reshetnikov (nikov)
Created Oct 8, 2009 12:36:22 PM
Updated Mar 27, 2012 5:03:10 PM
Priority Critical
Type Bug
Fix versions 7.0
State Open
Assignee Alexey Kuptsov (alexey.kuptsov)
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
using System.Data;
using System.Text;

class A
{
	public static string Foo(DataSet ds)
	{
		var message = new StringBuilder();
		for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
			message.Append(ds.Tables[0].Rows[i]["message"]);
		return message.ToString();
	}
}


Actual result:

	public static string Foo(DataSet ds)
	{
		var message = new StringBuilder();
		foreach (object t in ds.Tables[0].Rows)
			message.Append(t["message"]); // error CS0021: Cannot apply indexing with [] to an expression of type 'object'
		return message.ToString();
	}


Expected result:

	public static string Foo(DataSet ds)
	{
		var message = new StringBuilder();
		foreach (DataRow row in ds.Tables[0].Rows)
			message.Append(row["message"]);
		return message.ToString();
	}


Also, strange name 't' for iteration variable is selected and is not editable.

Viewing all articles
Browse latest Browse all 106942

Trending Articles