Incorrect decompilation for some language versions

Given this code:
public class Auxiliar2
{
    public IEnumerable<char> PercorreCaracteres(char start, char end)
    {
        if ((start < 'a') || (start > 'z'))
        {
            throw new ArgumentOutOfRangeException(nameof(start), "Carácter início incorreto.");
        }

        if ((end < 'a') || (end > 'z'))
        {
            throw new ArgumentOutOfRangeException(nameof(end), "Carácter final incorreto.");
        }

        if (end <= start)
        {
            throw new ArgumentException($"{nameof(end)} não pode ser inferior a {nameof(start)}");
        }

        return Cria();

        IEnumerable<char> Cria()
        {
            for (var c = start; c < end; c++)
                yield return c;
        }
    }
}

The decompilation for .NET 1.0 / C# 1 / VB 7 is correct:
public class Auxiliar2
{
    // Methods
    public IEnumerable<char> PercorreCaracteres(char start, char end)
    {
        <>c__DisplayClass0_0 class_ = new <>c__DisplayClass0_0();
        class_.start = start;
        class_.end = end;
        if ((class_.start < 'a') || (class_.start > 'z'))
        {
            throw new ArgumentOutOfRangeException("start", "Car\x00e1cter in\x00edcio incorreto.");
        }
        if ((class_.end < 'a') || (class_.end > 'z'))
        {
            throw new ArgumentOutOfRangeException("end", "Car\x00e1cter final incorreto.");
        }
        if (class_.end <= class_.start)
        {
            throw new ArgumentException(string.Format("{0} n\x00e3o pode ser inferior a {1}", "end", "start"));
        }
        return class_.<PercorreCaracteres>g__Cria0();
    }
}

But not for versions above that:
public class Auxiliar2
{
    // Methods
    public IEnumerable<char> PercorreCaracteres(char start, char end)
    {
        <>c__DisplayClass0_0 class_;
        if ((start < 'a') || (start > 'z'))
        {
            throw new ArgumentOutOfRangeException("start", "Car\x00e1cter in\x00edcio incorreto.");
        }
        if ((end < 'a') || (end > 'z'))
        {
            throw new ArgumentOutOfRangeException("end", "Car\x00e1cter final incorreto.");
        }
        if (end <= start)
        {
            throw new ArgumentException(string.Format("{0} n\x00e3o pode ser inferior a {1}", "end", "start"));
        }
        return class_.<PercorreCaracteres>g__Cria0();
    }
}

The code setting the fields of class_ is missing.
Paulo Morgado
Portugal
Web Site
Weblog
Twitter
Tagged:

Comments

  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi Paulo,

    Apologies for this and thanks for reporting it!

    I have gone ahead and logged this in our internal bug tracking system as RP-4039.

    I will post here once I have an update on this.

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


Sign In or Register to comment.