This is a migrated thread and some comments may be shown as answers.

Incorrect decompile transformation from compiler generated iterator classes to C# iterators

1 Answer 38 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 13 Apr 2012, 09:32 PM
Hi,

Version: 2012.1.409.0 SP1

There is an error with the transformation from the compiler generated classes for iterators to C# iterators. It seems that the captured variables are not being initialized.

For example, System.Linq.Enumerable::SkipIterator decompiles to the code below. You will notice that num is not initialized with the value of count.
private static IEnumerable<TSource> SkipIterator<TSource>(IEnumerable<TSource> source, int count)
{
    IEnumerator<TSource> enumerator = source.GetEnumerator();
    using (enumerator)
    {
        while (num > 0 && enumerator.MoveNext())
        {
            int num = num - 1;
        }
        if (num > 0)
        {
            goto Label0;
        }
        while (enumerator.MoveNext())
        {
            yield return enumerator.Current;
        }
    }
Label0:
    yield break;
}

Best Regards,

Chris

1 Answer, 1 is accepted

Sort by
0
Yordan Dikov
Telerik team
answered on 20 Apr 2012, 01:05 PM
Hi Chris,

 Thank you for pointing this issue out. We'll see what is causing it and we'll provide a fix in one of the future updates. Stay tuned and don't hesitate to contact us about anything in JustDecompile.

Regards,
Yordan Dikov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Yordan Dikov
Telerik team
Share this question
or