1

I am using an iterator block as coroutine, that is, I have an enumerator IEnumerator e; e was initialized, and in the middle of an iterator block, yield return 1; was used to hold the execution of the coroutine temporarily.

For the purpose of debugging, it is desirable to get where e was yielded, i.e., the stack frame of e. It may be viewed in the debugger, or it may be logged for future inspection.

But all I have is IEnumerator interface, which has only three methods and one property. And I can't figure out how to relate them to, say, System.Diagnostics.StackTrace.

Is it possible, or should it be possible?

EDIT: After immediately receiving two comments clearing up my question I really want to ask, the correct question is:

You have a yielded IEnumerator e. Is there a way to get, for mostly debugging purpose, as much info as possible on what would be the resumed state? The MethodBase together with file name and line number would be perfect.

4

0 回答 0