Red Gate forums :: View topic - What's should I do with this error...
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

What's should I do with this error...

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
lopin123



Joined: 07 Nov 2010
Posts: 5

PostPosted: Sun Nov 07, 2010 8:08 pm    Post subject: What's should I do with this error... Reply with quote

any solution/suggest for this problem using .NET Reflector ver 6.5.0.135?

Code:
[CompilerGenerated]
private sealed class <GetEnumerator>d__0 : IEnumerator<object>, IEnumerator, IDisposable
{
    private int <>1__state;
    private object <>2__current;
    public RolesRule <>4__this;
    public IDictionaryEnumerator <>7__wrap2;
    public IDisposable <>7__wrap3;
    public DictionaryEntry <item>5__1;

    [DebuggerHidden]
    public <GetEnumerator>d__0(int <>1__state)
    {
        this.<>1__state = <>1__state;
    }

    private void <>m__Finally4()
    {
        this.<>1__state = -1;
        this.<>7__wrap3 = this.<>7__wrap2 as IDisposable;
        if (this.<>7__wrap3 != null)
        {
            this.<>7__wrap3.Dispose();
        }
    }

    private bool MoveNext()
    {
        bool flag;
        try
        {
            switch (this.<>1__state)
            {
                case 0:
                    this.<>1__state = -1;
                    this.<>7__wrap2 = this.<>4__this.m_items.GetEnumerator();
                    this.<>1__state = 1;
                    goto Label_007D;

                case 2:
                    this.<>1__state = 1;
                    goto Label_007D;

                default:
                    goto Label_0090;
            }
        Label_0041:
            this.<item>5__1 = (DictionaryEntry) this.<>7__wrap2.Current;
            this.<>2__current = this.<item>5__1.Value;
            this.<>1__state = 2;
            return true;
        Label_007D:
            if (this.<>7__wrap2.MoveNext())
            {
                goto Label_0041;
            }
            this.<>m__Finally4();
        Label_0090:
            flag = false;
        }
        fault
        {
            this.System.IDisposable.Dispose();
        }
        return flag;
    }

    [DebuggerHidden]
    void IEnumerator.Reset()
    {
        throw new NotSupportedException();
    }

    void IDisposable.Dispose()
    {
        switch (this.<>1__state)
        {
            case 1:
            case 2:
                try
                {
                }
                finally
                {
                    this.<>m__Finally4();
                }
                return;
        }
    }

    object IEnumerator<object>.Current
    {
        [DebuggerHidden]
        get
        {
            return this.<>2__current;
        }
    }

    object IEnumerator.Current
    {
        [DebuggerHidden]
        get
        {
            return this.<>2__current;
        }
    }
}

Back to top
View user's profile Send private message
Clive Tong



Joined: 04 Dec 2008
Posts: 283

PostPosted: Mon Nov 08, 2010 1:12 pm    Post subject: Reply with quote

Hi.

The code you are seeing is generated by the C# compiler when the original code defines an Enumerator that uses "yield return". The code seems to be doing:

Code:

  foreach(DictionaryEntry entry in ...)
  {
    yield return entry;
  }


We are currently looking at how to generate a better decompilation for this construct.
Back to top
View user's profile Send private message
lopin123



Joined: 07 Nov 2010
Posts: 5

PostPosted: Tue Nov 09, 2010 2:24 am    Post subject: Reply with quote

Thanks for you Clive...In order to re-compile the source,what can I do to know at minimal a object or I just can delete the source and making my own object?
Back to top
View user's profile Send private message
Clive Tong



Joined: 04 Dec 2008
Posts: 283

PostPosted: Tue Nov 09, 2010 9:40 am    Post subject: Reply with quote

There will be code somewhere that makes an instance of the compiler generated class.

Code:

public IEnumerable<DictionaryEntry> Foo(...)
{
    <GetEnumerator>d__0 d__ = new <GetEnumerator>d__0(-2);
    d__.<>4__this = this;
    // maybe other arguments here
}


You can get rid of the compiler generated code if you change that definition to be:

Code:

public IEnumerable<DictionaryEntry> Foo(...)
{
    foreach(DictionaryEntry item in ...)
      yield return item;
}
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