How can we help you today? How can we help you today?

foreach nevereding loop issue

Hi,
I've found rather tricky case with foreach loop in exported sources.

sometimes C# code (break) is generated normal, eg:

for (int i = 1; i < list2.Count; i++)
{
bool flag = false;
foreach (c0002c7 cc2 in list3)
{
if (cc2.m000222() == list2.m000222())
{
flag = true;
goto Label_0132;
}
}
Label_0132:
if (!flag)
{
list3.Add(list2);
}
}


but in some tricky(?) cases it produces really strange (buggy?) construction, eg:

string str4 = string.Empty;
Label_0497:
foreach (string str5 in list)
{
bool flag = false;
foreach (string str6 in strArray)
{
if (string.Compare(str5, str6, true) == 0)
{
goto Label_0497;

}
}
if (!flag)
{
str4 = (str4.Length > 0) ? (str4 + "," + str5) : str5;
}
}

another one:
string str4 = string.Empty;
Label_045D:
foreach (string str5 in list)
{
bool flag = false;
foreach (string str6 in strArray)
{
if (string.Compare(str5, str6, true) == 0)
{
goto Label_045D;

}
}
if (!flag)
{
str4 = (str4.Length > 0) ? (str4 + "," + str5) : str5;
}
}


wow, only now I see that all these cases are 1:1, i.e. the same - but they are from different files!

but there are some others, similar:

Label_047C:
foreach (string str3 in list5)
{
flag3 = false;
foreach (string str4 in strArray)
{
if (string.Compare(str3, str4, true) == 0)
{
goto Label_047C;

}
}
if (!flag3)
{
break;
}
}
if (flag3)
{
list3.Add(cc4);
}

in my understanding instead of that goto after Compare there must be flag = true; break;
alehandro
0

Comments

6 comments

  • Clive Tong
    Hi.

    Do you have an example assembly that shows this problem?

    Thanks
    Clive Tong
    0
  • alehandro
    Sure
    /rapidshare.com/files/445278008/uo1.zip
    alehandro
    0
  • Clive Tong
    Thanks for the example. I've logged it as RP-958.
    Clive Tong
    0
  • alehandro
    Thank you

    Tell me please - I see lots of logged IDs, are these to be included in the nearest build? eg - Reflector 7 b2 or Release?
    just curious :)
    alehandro
    0
  • Clive Tong
    Hi.

    Version 7 is fairly locked down at the moment so we'll only be fixing serious bugs.
    Clive Tong
    0
  • alehandro
    Thanks
    anyway, please keep doing
    The tool is just superB
    alehandro
    0

Add comment

Please sign in to leave a comment.