Several bugs

Explore, browse and analyze .NET assemblies

Moderators: Luke Jefferson, Charles Brown, StephenC, Alex.Davies, Greg.Tillman, melvyn.harbour

Several bugs

Postby Romchick » Mon Oct 25, 2010 11:25 pm

Hi all,

There are several bugs in Reflector. Below are code snippets that reproduce the bugs:

Code: Select all
public struct ImplicitCastBug
{
    // Expected:
    // ((int)this).ToString();

    // Actual:
    // *(((int*) this)).ToString();
    public void TestMethod()
    {
        int i = this;
        i.ToString();
    }

    public static implicit operator int(ImplicitCastBug x)
    {
        return 0;
    }
}


This one generates code that compiles but is not equivalent to original:
Code: Select all
public class MissedClosureInitializationBug
{
    // To reproduce set optimization level to .NET 2.0 or higher.

    // Expected:
    // <>c__DisplayClass1 CS$<>8__locals2;
    // CS$<>8__locals2.x = 1;
    // this.AnotherMethod(new Action(CS$<>8__locals2, (IntPtr) this.<TestMethod>b__0));

    // Actual:
    // <>c__DisplayClass1 CS$<>8__locals2;
    // this.AnotherMethod(new Action(CS$<>8__locals2, (IntPtr) this.<TestMethod>b__0));
    public void TestMethod()
    {
        int x = 1;
        AnotherMethod(() =>
                          {
                              x++;
                              Console.WriteLine(x);
                          });
    }

    public void AnotherMethod(Action action)
    {
        action();
    }
}


This one is also generates non-equivalent code:
Code: Select all
public class TypeInferenceBug
{
    // To reproduce set optimization level to None.

    // Expected:
    //     bool b;
    //     int i;
    //     char c;
    //     bool CS$4$0000;
    //     b = false;
    //     i = 0;
    //     c = 'a';
    //     if ((((b != false) || (i == 0)) ? false : ((c == 'a') == false)) != false)
    //     {
    //         goto Label_001F;
    //     }
    // Label_001F:
    //     return;

    // Actual:
    //     bool b;
    //     int i;
    //     char c;
    //     bool CS$4$0000;
    //     b = 0;
    //     i = 0;
    //     c = 97;
    //     if ((((b != null) || (i == null)) ? 0 : ((c == 97) == 0)) != null)
    //     {
    //         goto Label_001F;
    //     }
    // Label_001F:
    //     return;
    public void TestMethod()
    {
        bool b = false;
        int i = 0;
        char c = 'a';
        if (b || i == 0 || c == 'a')
        {
        }
    }
}


Code: Select all
public class FixedBug
{
    // To reproduce set optimization level to .NET 1.0 or higher.

    // Actual:
    //     int[] CS$0$0000;
    //     int[] arr = new int[0];
    //     if (((CS$0$0000 = (arr == null) ? null : arr) != null) && (CS$0$0000.Length != 0))
    //     {
    //         goto Label_001D; // Compile error.
    //     }
    //     fixed (int* p = null) // Compile error.
    //     {
    //         goto Label_0025;
    //     Label_001D:
    //         p = CS$0$0000;
    //     Label_0025:
    //         this.AnotherMethod(p);
    //     }
    public unsafe void TestMethod()
    {
        int[] arr = new int[0];
        fixed (int* p = arr == null ? null : arr)
        {
            AnotherMethod(p);
        }
    }

    public unsafe void AnotherMethod(int* p)
    {
    }
}
Romchick
 
Posts: 2
Joined: Mon Oct 25, 2010 10:34 pm

Postby Clive Tong » Tue Oct 26, 2010 8:20 am

Thanks for reporting these. I've added them to the bug tracking system.
Clive Tong
 
Posts: 283
Joined: Thu Dec 04, 2008 5:42 pm

Postby Romchick » Fri Oct 29, 2010 1:09 pm

One more bug:

Code: Select all
    // Expected:
    // [DebuggerTypeProxy(typeof(NonGenericNestedClassBug<>.NestedClass))]

    // Actual:
    // [DebuggerTypeProxy(typeof(NestedClass<>))]
    [DebuggerTypeProxy(typeof(NonGenericNestedClassBug<>.NestedClass))]
    public class NonGenericNestedClassBug<T>
    {
        // Expected:
        // public NestedClass TestMethod()
        // {
        //     return new NestedClass();
        // }

        // Actual:
        // public NestedClass<T> TestMethod()
        // {
        //     return new NestedClass<T>();
        // }
        public NestedClass TestMethod()
        {
            return new NestedClass();
        }

        public class NestedClass
        {
        }
    }
Romchick
 
Posts: 2
Joined: Mon Oct 25, 2010 10:34 pm


Return to .Net Reflector 6.x and .NET Reflector 6.x Pro

Who is online

Users browsing this forum: No registered users and 0 guests