Adds support for targeting an async method's internal MoveNext method#514
Adds support for targeting an async method's internal MoveNext method#514pardeike merged 2 commits intopardeike:masterfrom
Conversation
… MoveNext with Attributes Co-authored-by: Michael Ripley <zkxs00@gmail.com>
|
What’s the difference to MethodType.Enumerator ? |
|
Well, with MethodType.Enumerator it fails to find the method to patch, as it looks for a newobj opcode - but the actual contents of async methods don't use that. Looking at an iterator method, those are also decorated with an |
|
Anything that would have to be changed/added for this? 👀 A game I'm working with has quite a few async methods, so it would be nice to target them more easily. |
|
I would still like to see if we can merge this with the existing api. You mentioned that this would break backwards compatibility, in what way would that be a problem? |
|
I just mentioned it as a consideration - I don't know how you handle that sort of thing for Harmony. Funnily enough, the way I understand it, renaming the Though even that could be avoided by defining it as a second entry in the enum with the same underlying value and marking the old one as obsolete / removing it with a major version release - though I don't know if you care about keeping that sort of compatibility. |
As the title says. This is particularly interesting for targeting an
asyncmethod with a transpiler, whether using Attributes or manually finding it with the addedAsyncMoveNextmethod in AccessTools.I'm not sure where the tests should go / how they should look, but I did test it on a game that I write mods for.
Works perfectly, although trying to use
IAsyncStateMachineas the type for the__instanceparameter causes aFormatExceptionfor invalid IL on the call to the patch method (that took a while to figure out).