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

Explore, browse and analyze .NET assemblies

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

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

Postby lopin123 » Sun Nov 07, 2010 8:08 pm

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

Code: Select all
[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;
        }
    }
}

lopin123
 
Posts: 5
Joined: Sun Nov 07, 2010 6:48 pm

Postby Clive Tong » Mon Nov 08, 2010 1:12 pm

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: Select all
  foreach(DictionaryEntry entry in ...)
  {
    yield return entry;
  }


We are currently looking at how to generate a better decompilation for this construct.
Clive Tong
 
Posts: 283
Joined: Thu Dec 04, 2008 5:42 pm

Postby lopin123 » Tue Nov 09, 2010 2:24 am

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?
lopin123
 
Posts: 5
Joined: Sun Nov 07, 2010 6:48 pm

Postby Clive Tong » Tue Nov 09, 2010 9:40 am

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

Code: Select all
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: Select all
public IEnumerable<DictionaryEntry> Foo(...)
{
    foreach(DictionaryEntry item in ...)
      yield return item;
}
Clive Tong
 
Posts: 283
Joined: Thu Dec 04, 2008 5:42 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