Comments
3 comments
-
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:foreach(DictionaryEntry entry in ...) { yield return entry; }
We are currently looking at how to generate a better decompilation for this construct. -
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? -
There will be code somewhere that makes an instance of the compiler generated class.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:public IEnumerable<DictionaryEntry> Foo(...) { foreach(DictionaryEntry item in ...) yield return item; }
Add comment
Please sign in to leave a comment.
[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; } } }