Bug 4529 - Foreach -> For refactoring is not available for nested foreach
Summary: Foreach -> For refactoring is not available for nested foreach
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: Trunk
Hardware: PC Linux
: Low enhancement
Target Milestone: ---
Assignee: Mike Krüger
Depends on:
Reported: 2012-04-19 13:44 UTC by Marek Safar
Modified: 2013-09-14 08:03 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Marek Safar 2012-04-19 13:44:07 UTC

Comment 1 Mike Krüger 2012-04-20 02:14:28 UTC
works for me - was the file valid ?
Comment 2 Marek Safar 2012-04-20 03:33:26 UTC
Yes, here is the full sample

			byte[] buffer;
			var sb = new StringBuilder ();
			sb.Append ('-').Append ('-');
			sb.Append (boundary);
			sb.Append ('\r').Append ('\n');

			for (int i = 0; i < nested_content.Count; i++) {
				var c = nested_content [i];
				foreach (var h in c.Headers) {
					sb.Append (h.Key);
					sb.Append (':').Append (' ');
					foreach (var v in h.Value) {
						sb.Append (v);
					sb.Append ('\r').Append ('\n');
				sb.Append ('\r').Append ('\n');
				buffer = Encoding.ASCII.GetBytes (sb.ToString ());
				sb.Clear ();
				await stream.WriteAsync (buffer, 0, buffer.Length).ConfigureAwait (false);
				// todo: too many locals
				await c.SerializeToStreamAsync (stream, context).ConfigureAwait (false);
				if (i != nested_content.Count - 1) {
					sb.Append ('\r').Append ('\n');
					sb.Append ('-').Append ('-');
					sb.Append (boundary);
					sb.Append ('\r').Append ('\n');
Comment 3 Mike Krüger 2012-04-20 13:40:08 UTC
It's about the case:

foreach (var x in ENUMERABLE) {

atm the conversion is only implemented for IList objects (index access). For for it would look like:

for (var iter = ENUMERABLE.GetEnumerator (); iter.MoveNext ();) {
   var x = (Type)iter.Current;

That isn't implemented yet and I'm not really sure about implementing it. I wouldn't say no when someone would contribute this conversion - but from my POV it's not really a code enhancement.
Comment 4 Mike Krüger 2013-09-14 08:03:20 UTC