R# 2.5.3 - Bug with "Iterate collection with foreach" action

Inside a code behind class of an aspx file, type "this.Controls" and press Alt+Enter. It will expand to

foreach (object o in this.Controls) {}

which is wrong, since it should be

foreach (Control c in this.Controls) {}

If I do this
1. type "this.Controls" -> CtrlAltV to introduce local variable "collection"
2. type "collection" -> Alt + Enter
it correctly expands to

foreach (Control control in collection) {}

seems like a bug to me that, in the first case, R# isn't able to correctly figure out the type of the iterator variable. Since I use the auto-iterate action many times a day, it is quite annoying for me.

Best regards,
Urs

1 comment
Comment actions Permalink

hello,
is there someone willing to comment on this? is this a (known) bug? will jetbrains do anything to correct this? is the bug still there in the 3.0 release (we're still using 2.5.3 as there doesn't seem to be a compelling reason for us to pay the upgrade price)?
regards,
urs

Inside a code behind class of an aspx file, type
"this.Controls" and press Alt+Enter. It will expand
to

foreach (object o in this.Controls) {}

which is wrong, since it should be

foreach (Control c in this.Controls) {}

If I do this
1. type "this.Controls" -> CtrlAltV to introduce
local variable "collection"
2. type "collection" -> Alt + Enter
it correctly expands to

foreach (Control control in collection) {}

seems like a bug to me that, in the first case, R#
isn't able to correctly figure out the type of the
iterator variable. Since I use the auto-iterate
action many times a day, it is quite annoying for
me.

Best regards,
Urs

0

Please sign in to leave a comment.