Skip to content
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

MethodDelegate: allow for swapping value type with object, and allow ref for arg 0 on value type #633

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Eddio0141
Copy link

This changes AccessTools.MethodDelegate to let you use object where a value type exists

Also lets you use ref for the first argument with value types, since currently you can't mutate structs from dynamic methods generated when open instance without boxing, so this lets you use delegates such as void MyFunc(ref UnityEngine.Resolution res);

@pardeike
Copy link
Owner

That’s nice work!

@pardeike
Copy link
Owner

Maybe you can add some tests too?

repeat mutation to see effect

fixed bind error

restore missing test
@Eddio0141
Copy link
Author

Thanks! Also sorry for the messy commits, I've squashed them to two commits to try make it clean
I've added 2 tests which should test the exact code, it is all done now and should be passing

Also I just realised, this fix would only apply for virtualCall: false, since delegates is incompatible normally, and this fixes just the dmd to handle these things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants