Red Gate forums :: View topic - Several bugs
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
.Net Reflector 6.x and .NET Reflector 6.x Pro
.Net Reflector 6.x and .NET Reflector 6.x Pro forum

Several bugs

Search in .Net Reflector 6.x and .NET Reflector 6.x Pro forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
Romchick



Joined: 25 Oct 2010
Posts: 2

PostPosted: Mon Oct 25, 2010 11:25 pm    Post subject: Several bugs Reply with quote

Hi all,

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

Code:
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:
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:
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:
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)
    {
    }
}
Back to top
View user's profile Send private message
Clive Tong



Joined: 04 Dec 2008
Posts: 283

PostPosted: Tue Oct 26, 2010 8:20 am    Post subject: Reply with quote

Thanks for reporting these. I've added them to the bug tracking system.
Back to top
View user's profile Send private message
Romchick



Joined: 25 Oct 2010
Posts: 2

PostPosted: Fri Oct 29, 2010 1:09 pm    Post subject: Reply with quote

One more bug:

Code:
    // 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
        {
        }
    }
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group