I have a dll which I disassemble in Reflector, I then generate a class.
The class contains code which does not compile in Visual Studio.
I take it it's leagl IL code, but how can I generate the higher level c# from this.
Seems yield and IEnumerator generate things like
private sealed class <Rule_Document>d__0 : IEnumerable<HtmlTag>, IEnumerable, IEnumerator<HtmlTag>, IEnumerator, IDisposable
private int <>1__state;
private HtmlTag <>2__current;
public HtmlParser <>4__this;
private int <>l__initialThreadId;
public HtmlTag <htmlTag>5__1;
That IL is from an iterator block. Iterators are horrible to write manually, and the underlying IL from an iterator block is testament to the reality of what the compiler does for you. Be grateful you didn't have to do it yourself!
You could try putting that together mainly from the
MoveNext(), but don't expect miracles. You may also find that renaming the fields (to get rid of things like
<> prefixes) goes a long way.
However; I expect the best thing to do is to understand what the code is trying to do, and stop trying to simply
steal borrow their implementation.