-
-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for targeting an async method's internal MoveNext method #514
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just that one tiny cleanup
As the title says. This is particularly interesting for targeting an
async
method with a transpiler, whether using Attributes or manually finding it with the addedAsyncMoveNext
method 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
IAsyncStateMachine
as the type for the__instance
parameter causes aFormatException
for invalid IL on the call to the patch method (that took a while to figure out).